The task of wanted to display posts from another site within our multisite setup in WordPress arose recently. We wanted to display recent posts from our Help Pages within the footer of our main site. The solution was very simple, we just added the following code into our themes footer.php file, although this can be put anywhere within your WordPress theme…

	global $switched;
	switch_to_blog(2); //switched to blog id 2

	// Get latest Post
	$latest_posts = get_posts('category=-3&numberposts=6&orderby=post_name&order=DESC');
	$cnt =0;
	<?php foreach($latest_posts as $post) : setup_postdata($post);?>
			<a href="<?php echo get_page_link($post->ID); ?>" title="<?php echo $post->post_title; ?>"><?php echo $post->post_title; ?></a>
	<?php endforeach ; ?>

<?php restore_current_blog(); //switched back to main site ?>
Free Graphics, Icons, Tutorials
Free Graphics Free Christmas Vector Icon Graphics Pack 2017Free Fitness Vector Icons Graphics PackFree Camping Vector Graphics PackFree Summer Graphics PackFree File Icon PackFree Fast Food Vector Graphics
Sharing is caring...
Like & Follow
Share the love, share this page! Facebook Twitter Digg Reddit LinkedIn Pinterest Email
Close [X]
The Web Taylor
1000 Lakeside North Harbour Portsmouth, Hampshire PO6 3EN
02392 123358