Exclude Most Recent Post From Archives (7 posts)

  1. mwselz
    Posted 9 years ago #

    Anyone have an idea of how to exclude the most recent post from the archives?

    My client wants a page with the most recent post on the top, then an archive list lower down. I can do that, no problem, but the archive list shows the most recent post -- meaning that post is listed twice on the same page.

    How can I set up the archives so that the most recent post doesn't show up?

    Many thanks -- I'm on a deadline, so if anyone has any idea, don't hesitate! :-)

    Thanks again.

  2. Michael Bishop

    Posted 9 years ago #

    I think the get_post tag has an offset parameter, perhaps that would be a starting point?

  3. mwselz
    Posted 9 years ago #

    Looks like get_post returns values for a specific post... not sure (having very little php-fu) how I would turn that around to exclude the most recent post.

    Thanks -- keep 'em coming!

  4. Michael Bishop

    Posted 9 years ago #

    Not from a specific post, it's more like a mini loop


  5. mwselz
    Posted 9 years ago #

    Hey, that's working *nearly* perfectly! The only thing is, it only shows the date on the first archive entry. Here's the code:

    $myposts = get_posts('numberposts=12&offset=1&orderby=post_date&order=DESC&category=2');
    foreach($myposts as $post) :

    <li><strong><a>"><?php the_title(); ?></a></strong>
    <?php the_date(); echo ""; ?>
    <?php the_excerpt(); ?>
    <?php endforeach; ?></li>

  6. Kafkaesqui

    Posted 9 years ago #

    the_date() is intended to display once per each day's worth of posts. So if you have 10 posts on a page and they were all published on the same day, the_date() would output only once.

    Instead, try out this little trick:

    <?php the_time(get_settings('date_format')); >

  7. mwselz
    Posted 9 years ago #

    That's got it! Thanks very much; everyone's been brilliant.

Topic Closed

This topic has been closed to new replies.

About this Topic