php - How can I show recent blogbost from wp multisites on my mainpage -


i'm having trouble wordpress. i'm rather new wordpress , not familiar how works. said, i'm working on project in wordpress incluedes main site , couple of different sub sites. i'm using wordpress multisites.

what want show latest blogpost every sub site on mainsite.

i know how fix 1 site:

<?php $the_query = new wp_query('posts_per_page=6'); ?>   <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>        <a href="<?php the_permalink() ?>"><div class="col-md-3 col-xs-12">        <p><i class="fa fa-user"></i> <?php the_author(); ?>       <i class="fa fa-clock-o"></i> <time><?php the_date(); ?></time></p>        <?php $email = get_the_author_meta('', $author); ?>       <?php $bild = get_avatar_url($email); ?>       <img src="<?php echo $bild; ?>" id="avatarimg">         <h3><?php the_title(); ?></h3>       </div></a>     <?php         endwhile;         wp_reset_postdata();      ?> 

the above codesnippet works single wordpress site , it's excactly how want works multiple sites.

what have managed fetch blogposts other sites using code:

<?php   $all_blog = get_sites();   foreach ($all_blog $key=>$current_blog) {     // switch each blog posts     switch_to_blog($current_blog->blog_id);       // fetch posts       $blog_posts = get_posts(array( 'posts_per_page' => 1));       restore_current_blog();         // display posts         echo $blog_posts[0]->post_content;   }  ?>  

this code gives me content recent blog posts blogs. havn't figured out how display data in first codesnippet.

i don't know how directly you.

but perhaps if take @ wpmudev autopost plugin code might find answer. used time ago thing.

b.r.


Comments

Popular posts from this blog

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

javascript - Confirm a form & display message if form is valid with JQuery -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -