WordPress.org

Ready to get started?Download WordPress

Forums

Next/Previous Post Links (2 posts)

  1. mildlyhotpeppers
    Member
    Posted 6 years ago #

    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?

  2. Cypher
    Member
    Posted 6 years ago #

    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..

Topic Closed

This topic has been closed to new replies.

About this Topic