• geotay

    (@geotay)


    I’m using 2.7.1

    I’m not looking to list just the latest single on the home/front page. This has nothing to do with the home page.

    What I want to do is display some info only on the latest single entry page. I’ve looked, read, searched, tried this, tried that, failed.

    If a person is viewing the single page for the latest entry include extra data otherwise display the entry as normal

    So lost on what has got to be much easier than I’m making it out to be.

    Any help? Much appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • MichaelH

    (@michaelh)

    Using WordPress Default theme for example;

    In the single post template, wp-content/themes/default/single.php, add this just before the loop:

    <?php
    $latest_post_ID=0;
    $latest_post=get_posts('showposts=1');
    if ($latest_post) {
    $latest_post_ID=$latest_post[0]->ID;
    }
    ?>

    And this inside the loop, say just before the_content:

    <?php if ($latest_post_ID == $wp_query->posts[0]->ID ) {
    echo ' Extra stuff for latest post';
    }
    ?>

    Thread Starter geotay

    (@geotay)

    Oh wow! I forgot that I asked about this. Thank you so much for your help.

    Thread Starter geotay

    (@geotay)

    Okie, I’m trying to understand your code and I just don’t. It works so big WOOHOO for that, but I hate not understanding why it works. I’m going to keep reading through the codex ’til something clicks… or I hope it eventually will.

    How would I do the reverse? Display some info on every single entry EXCEPT the latest one?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Including extra info ONLY in the latest single entry’ is closed to new replies.