'how is it possible to have multiple articles from sub-site shown on main wordpress site

I have 8-9 subsites on the main site. I would like to have at least 2-3 latest articles/posts from each of the subsite blogs on the main site home page. is there any plugin/widget that can do or is there any code that we can put in the main site theme to publish multiple posts from every single subsite



Solution 1:[1]

thank you @redfox however i used plugin network extended. that made it easier by using the shortcode and it helped to increase posts from every sub site to display on main site.

thank you

Solution 2:[2]

You can use the switch_to_blog function in order to query posts from any site on the network. Then, you might want to do something like:

// Switch to a particular site on the network
switch_to_blog( $site_id );

// Retreive the latest 3 posts
$args = array(
    'post_type'        => 'post',
    'posts_per_page'   => 3,
    'orderby'          => 'date',
     'order'           => 'DESC'
);
$latest_articles = new WP_Query( $args );

while ( $latest_articles->have_posts() ) {
    $latest_articles->the_post();
    // do some stuff such as the_title(), the_content(), etc.
}

// Restore the original query
wp_reset_query();

// Get back to the original site
restore_current_blog();

Hope that helps!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 deep.er
Solution 2 reddfox