I don't really know if I'm asking a question here. More just sharing thoughts I'm having as I butt up against the limitations of Post Indexer and WordPress...
On a multisite network I'm building, I need to be able to display posts from across the network in various places filtered on a range of criteria, including custom fields and taxonomy. So yay for Post Indexer :slight_smile:
However, I don't just want to show the post details. I also need to show the name and URL of the site each post originates from. It's proving really tricky to do this in an efficient way.
If I run a query with network_query_posts(), I'm asking WordPress to run a single query. If I then loop through doing a switch_to_blog() for each post to grab the site name and URL, my number of queries goes up massively, I'm guessing. If I show 20 results per page, I'd be making WP run 21 DB queries on each?
I think a more efficient method will be to have some kind of Site Indexer facility running as well, which captures summary information about each site when a site is added or updated. That way, one could query wp_network_posts, and join it to a wp_network_sites table to get results that list post details with the relevant site details.
As there are going to be only around 30-40 sites on our network for the near future, I think I'll look at building my Sites Index on the fly as an array, and then perhaps storing that as a transient to start with.
Unless there's some obvious magic with Post Indexer I'm missing?