Forums

[resolved] Adding 20 most recent posts to Sandbox homepage - how? (3 posts)

  1. AlternativePhotography
    Member
    Posted 2 years ago #

    I have a loop that displays the post title and excerpt. If I want to show the last 20 posts, how and where do I add this? I read i should use:
    <?php wp_get_recent_posts( $num ) ?>
    But my loop does not have that variable. My loop looks like this:

    <?php while ( have_posts() ) : the_post() ?>
    
    <div id="post-<?php the_ID() ?>" class="<?php sandbox_post_class() ?>">
    
    <h3 class="entry-title" style="margin-top:0px; padding-top:0px">
    
    <a href="<?php the_permalink() ?>" title="<?php printf( __('Permalink to %s', 'sandbox'), the_title_attribute('echo=0') ) ?>" rel="bookmark"><?php the_title() ?></a></h3>
    
    <?php
    $myExcerpt = get_the_excerpt();
    if ($myExcerpt != '') {
        // Some string manipulation performed
    }
    echo $myExcerpt; // Outputs the processed value to the page
    ?>
    </div>

    Really appreciate any advice!

  2. vtxyzzy
    Member
    Posted 2 years ago #

    Try putting this as the line above your 'while ( have_posts() )' line:

    $posts = query_posts($query_string . '&posts_per_page=20');

  3. AlternativePhotography
    Member
    Posted 2 years ago #

    Works great. Thank you so much! :-)

Topic Closed

This topic has been closed to new replies.

About this Topic