Forums

[resolved] Exclude Most Recent Post From Blog Page (5 posts)

  1. chickspirit
    Member
    Posted 2 years ago #

    Any help correcting my php code to have the most recent blog post excluded from my blog page?
    whoischick.com/blog/

    Original code:

    <?php
    if ($posts) {
    foreach($posts as $post) { start_wp();
    ?>

    What I changed it to but isn't working:

    <?php query_posts('offset=1'); ?>
    <?php if ($posts) {
    foreach($posts as $post) { start_wp(); ?>

    Thanks for the help.

  2. MichaelH
    Volunteer
    Posted 2 years ago #

    I'd think this should work, also might look at replacing start_up with setup_postdata.

    <?php query_posts($query_string . '&offset=1'); ?>
  3. chickspirit
    Member
    Posted 2 years ago #

    Thanks Michael for the quick reply.

    I tried it, but that darn latest post won't disappear.

    I'm using the benevolence theme and things don't always seem to translate well.

    Not sure what you mean by replacing start_up with setup_postdata.

    ...newbie trying to figure it out with lots of trial & error.

    Not sure if this affects things but I have a static front page of my site that shows the most recent blog post. Which is why I'd like the most recent blog post removed from the blog page.

    This is the code I used to have the most recent blog post show up on the front page.

    <?php
    $args = array(
      'numberposts' => 1
      );
    $posts=get_posts($args);
    if ($posts) {
    foreach($posts as $post) {
    setup_postdata($post);
    ?>
  4. MichaelH
    Volunteer
    Posted 2 years ago #

    This should work

    <?php
    $args = array(
      'offset' => 1
      );
    $posts=get_posts($args);
    if ($posts) {
    foreach($posts as $post) {
    setup_postdata($post);
    ?>
  5. chickspirit
    Member
    Posted 2 years ago #

    Thanks Michael.

    The last code you gave me worked but only after I went into the Dashboard under Reading settings and removed having the Posts Page pointed at a specific template.

    I had the Posts Page pointed at my Blog.php template file and in doing that it was strangely overriding any code I actually put in the Blog.php file.

Topic Closed

This topic has been closed to new replies.

About this Topic