I have a multisite wordpress installation with 5 sites, and within each site there are the same 4 custom post type,
I want to query the latest 5 posts across all sites where the post_type
is gallery
is it possible to get wp_query()
to pull across all blogs within the site instead of just the current blog?
Yes but not in a single query, e.g.:
If you want to show the latest post in each individual blog that should be easy. If you want to show the individual newest post across the entire network, you’ll need to find the newest of each blog, you will need to store the newest post found, replacing ti when a newer post is found, then outputting after the loop.
switch_to_blog is VERY expensive… here is some code I use (I use my own pager and query vars)