WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to exclude most recent post (5 posts)

  1. ehsen
    Member
    Posted 5 years ago #

    I want to show posts on my homepage the regular way but wanna exclude the most recent post. Can you please tell which tag I have to include in my template.

  2. If you want to exclude the most recent post from the loop, then you can use query_posts() with the offset parameter. Usually, index.php starts the loop with if (have_posts()), but if you want to use query_posts() and exclude the most recent post, then you would change it to if (query_posts('offset=1')). Be careful when editing template files, and don't forget to make a backup before you begin.

  3. 3wlink
    Member
    Posted 5 years ago #

    Nice solution. But when i use "if (query_posts('offset=1'))" instead of
    "if (have_posts())", the navigation link (previous entries, next entries) doesn't work. Url shows that it goes to the 2nd page, but the contents remain same.

    Can I have any solution please?

  4. 3wlink, it works with the query OUTSIDE the loop :)

    <?php query_posts('offset=1'); ?>
    	<?php while (have_posts()) : the_post(); ?>
    			Post foo
    	<?php endwhile; ?>
  5. dar3devil
    Member
    Posted 4 years ago #

    Ipstenu i have the same problem.
    I used it outside the loop and the navigation links doesn't work either.
    What should i do ?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.