Support » Plugins » Selecting the most recent post for special treatment

  • Looking to hack the code of single.php so that I can add a link to the next story.
    We currently use the nav-above/nav-below links in Sandbox to get from one story to the next. The client would like to have the first story link with different text from the headline.

    Need to isolate the latest post and have a link like “Check out more news…”
    Would like to leave all other posts as they currently are.
    Site in question is:

    Thanks in advance

Viewing 7 replies - 1 through 7 (of 7 total)
  • For the more code savvy users, would it be possible to count the number of posts and return that variable for use in an IF statement?

    Something like:

    $MostRecent = HowManyPostsAreThere
    if (is_post('$MostRecent')) echo (blah blah)
    (do nothing)

    Would something like this work or be possible?
    Not sure of the actual code involved.
    Any help?

    No that won’t work.
    No relationship between number of posts and the postID apparently.
    Keep trying.

    So on further research
    <?php $newest_post_id = $posts[0]->ID; ?>
    does the job of identifying the most recent post.

    With this pearl, can someone tell why this would not work.

    <?php $newest_post_id = $posts[0]->ID; ?>
    <?php if(the_ID == $newest_post_id) {
    echo 'yes';
    } else {
    echo 'no';

    Check this reply:

    Would that work for you?

    hmmm, not sure that it does.
    I am trying to modify single.php and that example looks like it would work for the list of posts in my limited experience.

    Thanks though!

    apologies – I skimmed your OP and totally missed the point! :-\

    Did you find a solution to this problem?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Selecting the most recent post for special treatment’ is closed to new replies.