Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1063677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:49:06+00:00 2026-05-16T18:49:06+00:00

I am trying to get the thumbnail meta data for the posts in my

  • 0

I am trying to get the thumbnail meta data for the posts in my wordpress blog together with their category and some other data.
The thumbnail data is serialized and I will unserialize it later.

Here is the query I have:

    SELECT wpostmeta.meta_value AS url,
    wposts.post_content, wposts.post_title, wposts.post_status, wposts.post_name,
    cat_terms.name AS category_name, cat_terms.term_id AS category_id,
    ttable.meta_value AS thumb_data
    FROM `wp_postmeta` AS wpostmeta,
    `wp_posts` AS wposts
    INNER JOIN wp_term_relationships AS cat_term_relationships ON (wposts.ID = cat_term_relationships.object_id)
    INNER JOIN wp_term_taxonomy AS cat_term_taxonomy ON (cat_term_relationships.term_taxonomy_id = cat_term_taxonomy.term_taxonomy_id AND cat_term_taxonomy.taxonomy = 'category')
    INNER JOIN wp_terms AS cat_terms ON (cat_term_taxonomy.term_id = cat_terms.term_id)
    LEFT JOIN `wp_postmeta` AS ttable ON (wposts.ID = ttable.post_id AND ttable.meta_key = '_wp_attachment_metadata')
    WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = 'url'
    AND wposts.post_type = 'post'

Everything works except for the attachment part. ‘thumb_data’ is NULL.

Could you please help me fix this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T18:49:07+00:00Added an answer on May 16, 2026 at 6:49 pm

    This query solved my problem:

    $sql = "SELECT wposts.ID AS ID, thumbposts.ID AS thumbposts_ID,
            postmeta.meta_value AS url,
            wposts.post_content, wposts.post_title, wposts.post_status, wposts.post_name,
            cat_terms.name AS category_name, cat_terms.term_id AS category_id,
            thumb.meta_value AS thumb_data
    
            FROM `wp_postmeta` AS postmeta,
            `wp_posts` AS thumbposts,
            `wp_postmeta` AS thumb,
            `wp_posts` AS wposts
    
            INNER JOIN wp_term_relationships AS cat_term_relationships ON (wposts.ID = cat_term_relationships.object_id)
            INNER JOIN wp_term_taxonomy AS cat_term_taxonomy ON (cat_term_relationships.term_taxonomy_id = cat_term_taxonomy.term_taxonomy_id AND cat_term_taxonomy.taxonomy = 'category')
            INNER JOIN wp_terms AS cat_terms ON (cat_term_taxonomy.term_id = cat_terms.term_id)
    
            WHERE wposts.ID = postmeta.post_id
            AND postmeta.meta_key = 'url'
    
            AND thumbposts.post_parent = wposts.ID
            AND thumbposts.post_type = 'attachment'
    
            AND thumb.post_id = thumbposts.ID
            AND thumb.meta_key = '_wp_attachment_metadata'
    
            AND wposts.post_type = 'post'";
    
        if($filter == 1){
            $sql .= " AND cat_terms.term_id = '1'";
        }
        if($filter == 2){
            $sql .= " AND cat_terms.term_id = '3'";
        }
    
        $sql .= " GROUP BY wposts.ID
            ORDER BY wposts.post_date ASC";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get my Wordpress theme to pull up a thumbnail image for
I am trying to get a user's thumbnail from another intranet site but some
I'm trying to get video thumbnails from Vimeo, but for some reason, I cannot
I am running a plugin called Category Posts Widget for WordPress: http://wordpress.org/extend/plugins/category-posts/ It uses
I'm trying to get a thumbnail of flickr pictures in PHP. All I saw
I'm trying to get a Video Thumbnail from Streaming Video when touched to a
I'm trying to get a thumbnail to link to a PDF of the same
every one i am trying to get the video frame or thumbnail from a
I have been trying for several hours now to get sorl-thumbnail working, but it
I get the following data from the Instagram API , I m trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.