Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

modifiedcontent on "Get latest posts from all sites across multisite network - 2016 solution"

$
0
0

I tried to post this elsewhere on the Wordpress forums, I think that broke some rules again. Mercy!

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 wp_get_sites() + 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 post 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.


Viewing all articles
Browse latest Browse all 8245

Trending Articles