WordPress.org

Ready to get started?Download WordPress

Forums

Pulling Network Wide Recent Posts - Limit to 5 (1 post)

  1. myladeybugg
    Member
    Posted 1 year ago #

    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 30x30, but I'm not sure if that it's possible.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.