0

How I can get the next post URL when I'm on the last page ?

e.g. I want go to the nextpost when i'm on the last page...

This code need some tweak...

Here is my Function:

function next_page( $i ) {
    global $page, $numpages, $multipage, $more, $pagenow;
    if ( $multipage ) {
        if ( $more ) {
            $i = $page + 1;
            if ( $i <= $numpages && $more ) {
                $output .= _wp_link_page( $i );
            }
        }
    }
    if ( preg_match( '/href="([^"]+)"/', _wp_link_page( $i ), $match ) )
    return $match[1];
}

Best regards.

  • What does "nextpost" mean when you are on the last page? If you are on the last page there isn't a next one? And why aren't you using paginate_links() or some other Core function? – s_ha_dum Oct 21 '15 at 13:22
  • When i say "last page" i mean by using the <!--nextpage--> function e.g. when i'm on the last page of an article ( page 4/4 ) then the next button will go to the next article (next_post). – mems Oct 21 '15 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.