WordPress.org

Support

Support » Themes and Templates » Next/Previous Post Links

Next/Previous Post Links

  • Is there a way to check if the next_post_link() function will return a link? I’m creating a webcomic, and for the navigation I want to use next_post_link() to point to the next comic. When there isn’t a next comic, I want to show a “dimmed” out (i.e. gray colored) “Next” to give the impression that the Next button is “disabled.”

    Right now I have

    <?php $next_link = next_post_link('%link', 'Next', TRUE);
    if ($next_link == '') { ?>
    <font color="#666666">Next</font>
    <?php }?>

    but it doesn’t seem to work, and it prints out both when there is a next post.

    Can anyone help?

Viewing 1 replies (of 1 total)
  • The next/previous_post_link functions don’t return any data. They will just echo a next or previous link if one exists, and if not, nothing is echoed.

    If you wanted to do the echoing yourself, you would have to modify the WP core code in the /wp-includes/link-template.php file..

Viewing 1 replies (of 1 total)
  • The topic ‘Next/Previous Post Links’ is closed to new replies.