WordPress.org

Support

Support » Multisite » Pulling Network Wide Recent Posts – Limit to 5

Pulling Network Wide Recent Posts – Limit to 5

  • I am pulling recent blog posts network wide using this code:

    <?php
    $blogs = get_last_updated();
    
    foreach ($blogs AS $blog) {
    
    switch_to_blog($blog["blog_id"]);
    $lastposts = get_posts('numberposts=1');
    foreach($lastposts as $post) :
    setup_postdata($post);
    ?>
    
     <a href="<?php the_permalink(); ?>" style='color:white !important; margin-bottom: 5px;'><?php the_title(); ?></a></li></ul> <br />
    
     <p><?php printf( _x( 'by %s', 'Post written by...', 'buddypress' ), bp_core_get_userlink( $post->post_author ) ); ?></p>
    
    <?php
    endforeach;
    restore_current_blog();
    }
    ?>

    I would like to limit it to only pull the 5 most recent posts, but can’t seem to figure it out. I would also like to pull the author’s avatar, size 30×30, but I’m not sure if that it’s possible.

  • The topic ‘Pulling Network Wide Recent Posts – Limit to 5’ is closed to new replies.
Skip to toolbar