This is one way how to get the postmeta of the posts, by joining the postmeta table and fetching the _wp_attached_file
meta value.
Try this:
$mydb->get_results( select a.*, thumb.meta_value
from wp_posts a
left join (select b.post_id, c.meta_value
from wp_postmeta b, wp_postmeta c
where b.meta_key = '_thumbnail_id'
and b.meta_value = c.post_id
and c.meta_key = '_wp_attached_file') as thumb
on thumb.post_id = a.ID
where a.post_type="post"
and a.post_status="publish", OBJECT );
Related Posts:
- Optimizing Query used for a Shortcode
- WP MS: How to query over the network
- Multisite posts in categories on network
- find a random blogid across my multisite network that has at least one post published
- WP_Site_Query vs. WP_Network_Query in WordPress 4.6
- Creating a Post form outside of the Admin
- Using $wpdb Class to Pull Recent Comments Across a Network
- How to order by blog ID in this multisite ‘List Blogs’ custom function
- Bootstrapping WordPress MultiSite Outsite of WordPress – No $wpdb
- Retrieving multisite blog IDs, somehow failing to foreach them properly
- Network Plugin Creating Pages for Different Subdomains
- Use WordPress MultiSite (WPMS) with a remote database for each created site
- get_post_meta fails after switch_to_blog
- Update post meta using save_post hook in multisite
- How to display users with posts published between two dates (Sorted by Post-Count) [Multisite]
- WordPress query posts with multiple post_meta data
- Check if current site ID and value exist in WPDB
- Multi-site site nav, wpdb->prepare missing argument
- Can I replace the “Upgrade Network” with SQL query?
- Use $wpdb->get_results with filter based on array
- Get multisite count without php?
- WP DB Location for “Next Post to Create” Index Value
- Run “get_the_post_thumbnail” with a different table prefix?
- Adding an orderby filter, casting postmeta with multiple keys
- Retrieve post data via WPDB class
- WordPress MS wp-admin/includes/post.php error with shortcode generator
- How can meta values from another site in a multisite be used in a custom query?
- wp option get blogname –url=my-sub-site.com returning main site option
- Migration: previous URL redirection after migrating
- Sorting my posts on homepage my specific value in post_meta table
- Create link preview for theme wordpress
- How to update wordpress content of wordpress multi-site subdomain
- User registration on wordpress multisite
- On a multisite environment, get the subdomain value as variable
- Add www to the Root Site in WP Multisite Network
- Multisite Subdomain Change
- mu activate / deactivate plugins in multisite network mode only
- How can ı change my logo for specific page?
- Multisite problem with unexisting paths to CSS etc
- Cross site identifier in a WP Multisite installation
- Get data from custom table and update relative post_meta based on meta_key
- How to use the same users table on multiple wordpress sites
- How do I export a single site in a multisite content without using a plugin? The default WP export does not catch all
- Multisite Dashboard Always Redirects to Main Dashboard
- Multisite Smtp Server
- Images uploaded after adding multisite do not get loaded in any domain of the multisite network
- Migrating from domain mapping plugin to native domain mapping
- How to insert a value to decimal type field using wpdb->prepare?
- Customising the default wordpress search functionality
- Multisite install with subdomains on a subdomain
- Does this archive template part look like its making too many calls to the db?
- Error while localizing communityEventsData in script-loader.php
- A database for each category?
- Redirect a WordPress Multisite url after it has been change to a new one
- query multisite blog for post by tag
- Structure of multilingual and multiregional directory listing website for translation
- WordPress Multisite on multiple sub-domains
- how to convert a wp multisite into a single site with content from subsites
- Getting stylesheet error after setting subdomain to false in multisite
- Easily adding multiple existing users to a multisite site
- Bitnami multisite change URL of secondary blog
- Multisite loads assets from main site
- Tracing non-uniform slowdown on a multisite install with multiple domains
- Export / import
- Remember language choice on multisite website
- Language per user role, how can I achieve this?
- Insert NULL value using prepare()
- Internet explorer not finding right content from multisite
- Change WordPress multisite to sub-folder installation
- Admin users not able to see network menus
- WP-CLI Error Requesting CURL Extension
- Allowing users to manually add or remove themselves to/from WordPress multisite blogs
- Multisite: How to get a list of sites by locale
- WordPress Multisite loads wrong subdomain dashboard
- Any way to use FETCH_KEY_PAIR with $wpdb?
- Media library links broken WordPress Multisite after SSL update
- Redirecting specific sites to HTTP in WordPress Multisite
- Serve theme and plugins assets from correct domain on multi-domain multisite
- When hooking wp-cron to system
- Redirect Function Prevents Images from Showing in Front-end Media Uploader
- Moving from a non WordPress site to a WordPress Site – Login between both sites
- wp cli search and replace on –network Error reconnecting to the database
- In Multisite – main site blog post should be display in minisite or subsite
- Can I use the main Multisite as a backend only?
- Possible to reverse proxy WP multisite to a separate server with NGINX?
- How to securely controlling data without keeping it in postmeta?
- How to hold posts and accounts for moderation on WordPress Network site
- “Multisite support is not enabled.” After Multisite Config Changes
- Problems with WordPress multisite directories/url structures and admin access after migration
- Number of total comment does not tally with the number of comment?
- How to get inserted row IDs for bulk/batch insert with wpdb query?
- String translation within WordPress multisite with i18n not working on all sites
- multisite 404 subfolder same name slug as site
- Display posts from one network site on another
- “BS_” rows in postmeta table
- Delete oldest wordpress post (SQL query)
- Website creation for multiple clients but from a single account on multiple host name
- After switch domain, some parts of my site still point to my old domain
- Is mature Multisite
- Doing $wpdb->get_results returns NULL, doing the same query in my DB returns correct value