Site/blog details to go with Post Indexer

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?

  • Vinod Dalvi

    Hi Mina,

    I hope you are well today and thanks for posting on the forum.

    The Post Indexer plugin calls the function switch_to_blog only first time when he creates index of posts and save that indexed post in the following custom tables, thereafter it just fetches the stored data from the following tables instead of calling the function switch_to_blog.

    // tables list
     'site_posts', 'term_counts', 'site_terms', 'site_term_relationships' ,  'network_posts', 'network_rebuildqueue', 'network_postmeta', 'network_terms', 'network_term_taxonomy', 'network_term_relationships', 'network_log'

    Please advise if you have more questions.

    Best Regards,
    Vinod Dalvi

  • Rainbow Web Services

    Thanks, Vinod. Just to clarify though - Post Indexer indexes information about posts, terms and postmeta in those tables, but it doesn't index any information about the originating sites those posts came from?

    If true, I can't help think that's a flaw in all the plugins WPMUDEV builds on top of Post Indexer - they can all list posts beautifully, but can't generate listings that include the site details with each post. I think that's a navigation problem - showing a list of posts on different sites, without providing any indication of which site each link will take you to...

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.