Recent Posts from Multisite/Network

Hello!

I’m working within a multisite environment where the blog will be hosted on another site within the network. From my “main” site, is there anyway to adjust the Recent Posts shortcode to display from a different blog ID?

Thanks so much!

Hello There,

The recent posts element will display post items within the blog or site. There aren’t any features that you can display post items from other blog ID or site. What you can do is to use the RSS widget to display post items from other site or blog. You can find the RSS widget in Appearance > Widgets and add it in your sidebar. To know more about this widget, please check this out: https://en.support.wordpress.com/widgets/rss-widget/

Thank you for your understanding.

Hi RueNel,

That’s what I was expecting, but thought I would ask. I’d like to share my solution in case anyone comes across it:

Goal: I needed to display recent posts from a sub-site blog on my main site within a multi-site network.

Solution: I used RSS feeds for the blog in question (http://www.website.com/subsite/feed) through “The Grid” plugin

Additional Goal: I wanted to ensure the posts’ featured images would be displayed. Through some research, I found the following code and added to the my functions.php within my X Child Theme:

// =============================================================================
// Add Featured Image to RSS Feed
// =============================================================================

function fire_add_rss_item_image() {
global $post;
if( has_post_thumbnail( $post->ID ) ) {
$image_id = get_post_thumbnail_id( $post->ID );
$url = wp_get_attachment_url( $image_id );
$file_type = wp_check_filetype( basename( $url ) );
$image_type = $file_type[‘type’];
$attach = wp_get_attachment_metadata( $image_id );
$upload_dir = wp_upload_dir();
$length = 0;
$file = $upload_dir[‘basedir’] . ‘/’ . $attach[‘file’];
if ( file_exists( $file ) ) {
$length = filesize( $file );
}
echo “\t<enclosure url=”{$url}" length="$length" type="{$image_type}" />\n";
}
}

add_action( ‘rss2_item’, ‘fire_add_rss_item_image’ );
add_action( ‘rss_item’, ‘fire_add_rss_item_image’ );

// =============================================================================
// [END} Add Featured Image to RSS Feed
// =============================================================================

Hopefully this may help someone in the future.

Thanks for the support, take care!

Hello There,

You are most welcome.
The information on how you have accomplished on what you have in mind is very helpful and a good resource material for other users.

Best Regards.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.