Forum Replies Created

Viewing 1 replies (of 1 total)
  • Forum: Plugins
    In reply to: If Next_Posts_Link is Null?
    russelluresti

    (@russelluresti)

    I couldn’t find a very easy way to do this either, so I just copied what WordPress was already doing in get_next_posts_link().

    <?php
        if ( !$max_page ) $max_page = $wp_query->max_num_pages;
    
        if ( !$paged ) $paged = 1;
    
        $nextpage = intval($paged) + 1;
    
        if ( !is_single() && ( $nextpage <= $max_page ) ) {
    ?>

    That block evaluates to true if there ARE more posts to show — so in here I have my call to next_posts_link(‘More’). If you want to do something when there aren’t any more posts to show, just put in an “else” clause after the last “if”.

Viewing 1 replies (of 1 total)