Forums

Check if there are previous entries (5 posts)

  1. selder2
    Member
    Posted 5 years ago #

    I need to do something like this:

    <?php
    $navavailable == next_posts_link('&laquo; Previous Entries');
    if ($navavailable != "")
    { ... }
    ?>

    But as I thought, the code in the if statement is displayed . Is there any way to check if there are 'previous entries' using that wordpress tag?

  2. Kafkaesqui
    Moderator
    Posted 5 years ago #

    Try:

    <?php
    if ( !get_next_post() )
    { ... }
    ?>

  3. selder2
    Member
    Posted 5 years ago #

    Seriously! that worked! (without the ! though)

  4. Kafkaesqui
    Moderator
    Posted 5 years ago #

    "without the ! though"

    Oops. Misread your code. It was a long day yesterday...

  5. selder2
    Member
    Posted 5 years ago #

    Mmm ... I got it working when I posted my previous reply, and I'm sure I wasn't dreaming or looking somewhere wrong!

    But now it doesn't work anymore, and I don't know what is causing it! Darn!

    Here is my code (which is not displayed at all now)


    <?php
    if (get_next_post())
    {
    echo "<div class=\"navigation\">";
    echo "<div class=\"alignleft\">";
    echo next_posts_link('&laquo; Previous Entries');
    echo "</div>";
    echo "<div class=\"alignright\">";
    echo previous_posts_link('Next Entries &raquo;');
    echo "</div>";
    echo "</div>";
    }; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic