• I am using a a little menu for the lasted post on my single pages. I just want to have the first excluded from this list, if the single page displays the lasted post.

    I am currently doing this by hand:

    <?php
    global $post;
    if (is_single('239')) {
    $posts = get_posts('numberposts=4&offset=1');
    } else {
    $posts = get_posts('numberposts=4&offset=0');
    };
    foreach($posts as $post) :
    setup_postdata($post);
    ?>

    Is there any way like
    is_single(lastest_post)

    ???

Viewing 2 replies - 1 through 2 (of 2 total)
  • I’m not 100% sure of what you’re trying to do, but it seems like you could do this with the $do_not_duplicate technique offered in this explanation of The Loop.

    You’d essentially modify the original loop on single.php to include $do_not_duplicate = post->ID; and then make your next loop excludes $do_not_duplicate. I don’t feel like writing out and testing the thing, but it seems like it would do what you want.

    This might help:

    <?php
          $i=0; // Initialize to Zero;
          if (have_posts()) :
            while (have_posts()) : the_post();
                if ($i==0) {$recentpostid = $post->ID; $i=$i+1;}
            endwhile;
          endif;
          //get only the latest post
          $posts = query_posts( 'p='.$recentpostid."'");
    ?>
    <?php echo $recentpostid ;?>

    (from another thread)

    I’m trying something similar. I have a list of posts, and one displayed. Without reloading the page, I want to be able to click the next post title, and have it displayed. So far so good with an iframe. However, I can’t get my single.php that’s my iframe to load initially with the latest post. Let me know if you figured this out.

    Best, seej

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘is_single get the lasted post’ is closed to new replies.