Get latest posts from all sites across multisite network – 2016
-
What is the latest, best solution to get recent posts from across a multisite network on your central home page?
The network-latest-posts plugin is not a solution; it requires you give it blog ID’s from the blogs in your network.
I am looking for an aggregator that automatically collects the latest posts from dozens, maybe hundreds of sites, without killing the server.
The solution should probably use a combination of wp_get_sites() with get_last_updated().
This proof-of-concept snippet is floating around:
<? $blogs = get_last_updated(); echo ' <h1>Last posts in network</h1> '; foreach ($blogs AS $blog) { echo " <h2>".$blog["domain"].$blog["path"]."</h2> "; switch_to_blog($blog["blog_id"]); $lastposts = get_posts('numberposts=1'); foreach($lastposts as $post) : setup_postdata($post); the_title(); endforeach; restore_current_blog(); } ?>
This one from 2011 has some kind of solution, but it is producing an annoying syntax error and I can’t figure out how to fix it:
http://www.smashingmagazine.com/2011/11/wordpress-multisite-practical-functions-methods/
So what is the latest? Has anyone else worked on this? Can someone put this together, point me in the right direction?
I have another old multisite network latest posts aggregator script that I could post, but it looks very messy.
- The topic ‘Get latest posts from all sites across multisite network – 2016’ is closed to new replies.