WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Select x most recent posts? (5 posts)

  1. prologuemedia
    Member
    Posted 5 years ago #

    How do you select the x most recent posts and display them via the_loop? I am wanting to create a little summary on the homepage that puts the 3 most recent posts in little boxes along with the title, an image and the first sentence or two. I was going to use the "more" tag to limit the content but, I wasn't sure how to limit the loop output.

    -gl

  2. Saurus
    Member
    Posted 5 years ago #

    Dashboard.

  3. MichaelH
    Member
    Posted 5 years ago #

    Here's one example to put before your loop:

    <?php
    if (!is_paged()) {
    $my_query = new WP_Query('showposts=3');
    while ($my_query->have_posts()) : $my_query->the_post();
    the_title();
    the_excerpt();
    endwhile;
    }
    ?>

    Resources:
    Stepping Into Template Tags
    Stepping Into Templates
    Template Hierarchy
    The Loop
    Template Tags
    query_posts()

  4. prologuemedia
    Member
    Posted 5 years ago #

    Thank you!

  5. MichaelH
    Member
    Posted 5 years ago #

    You are welcome. Marking this resolved.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags