Viewing 5 replies - 1 through 5 (of 5 total)
  • Say “Main Entries” has category id of 2

    <?php $posts = get_posts( "category=2&numberposts=5″ ); ?>
    <?php if( $posts ) : ?>

    <div id="latestMainEntries">
    <h3>Main Entries</h3>
    <ul>
    <?php foreach( $posts as $post ) : setup_postdata( $post ); ?>

    <li><span class="date"><?php the_time('F j'); ?></span> <a href="<?php the_permalink() ?>" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></li>

    <?php endforeach; ?>
    </ul>
    </div>

    <?php endif; ?>

    Thread Starter TCLongLPC

    (@tclong)

    Thank you!!!!!!!!!!!!!!!!

    Thread Starter TCLongLPC

    (@tclong)

    That works very well!
    I even included an additional IF statement to exclude the most recent entry.


    <?php $posts = get_posts( "category=1" ); ?>
    <?php if( $posts ) : ?>
    <?php $counter = 1; ?>
    <?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
    <?php if ($counter > 1) : ?>
    <li><center><a href="<?php the_permalink() ?>" title="Permanent Link to <?php the_title(); ?>" target="_blank"><?php the_title(); ?></a></center></li>
    <li><span class="date"><center><?php the_time('F d, Y'); ?></center></span></li><p>
    <?php $counter = $counter + 1; ?>
    <?php endif; ?>
    <?php $counter = $counter + 1; ?>
    <?php endforeach; ?>
    <?php endif; ?>

    Actually, the following is a better method than yours.
    $posts = get_posts( "category=1&numberposts=5&offset=1″ );

    Thread Starter TCLongLPC

    (@tclong)

    HEH! Darn, you’re right. And I thought I was being pretty clever… ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘listing previous posts’ is closed to new replies.