WordPress.org

Ready to get started?Download WordPress

Forums

Ambrosite Next/Previous Post Link Plus
[resolved] Check if there are any previous posts. (2 posts)

  1. mattmatt88
    Member
    Posted 1 year ago #

    Hello I have a Custom Post Type:

    previous_post_link_plus(
    array( 'meta_key' => 'event_startdate',
    'order_by' => 'custom',
    'link' => '<div class="previous-post">&laquo; %title</div>',
    'format' => '%link',
     ));

    If there are no previous posts, I want to echo something else.

    How can I do this?

    Thank you

    http://wordpress.org/extend/plugins/ambrosite-nextprevious-post-link-plus/

  2. ambrosite
    Member
    Plugin Author

    Posted 1 year ago #

    This is answered in the documentation, in the section that explains the usage of the 'return' parameter. You need to test the return value of the function. If it returns false, then no next/previous link was found:

    <?php if ( !previous_post_link_plus() ) {
        echo '<span class="inactive">« Previous</span>'; // if there are
    no older posts
    } ?>

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.