PHP problem, using if command to show pager

  • Unknown's avatar

    Hello All,

    I have a problem with using the pager function of wordpress. I want to show the “previous post” when there is a previous post, if there is no previous post I wan it to say “this is the oldest post.”

    I am using the if command of php to get this working. below is my code.

    <?php if( $prev_post) { ?>
      <?php previous_post_link('%link','<i class="fa fa-chevron-circle-left"></i> %title', true)  ?>
    <?php }else {?>
      This is the oldest post
    <?php }  ?>

    Now, it shows the “previous post” when it has it. But it does not show the text “This is the oldest post” when there is none. I suspect that I am using the else part wrong. Can anyone give me advice as to how I can get this resolved?

    Thanks in advance

    PS: I know my English is bad :(

  • Sounds like you’re running a self-hosted site with the WordPress software running on your own hosting, is that right? If that’s the case, you’ll need to get help over at WordPress.org, since these forums are for folks hosted here at WordPress.com, where we do not have access to the PHP code.

    http://wordpress.org/support/

    You’ll need a free WordPress.org account to post – if you don’t already have one, you can register here:

    https://wordpress.org/support/register.php

    Good luck!

  • Unknown's avatar

    Dear kathrynwp,

    Thank you for letting me know about this :) It is HUGE help since you led me to the right way :)

    Thank you so much!!

  • My pleasure! Hope you can get your code sorted out over there. :)

  • The topic ‘PHP problem, using if command to show pager’ is closed to new replies.