4

Here is my Function

function next_pages( $args = '' ) {
    $r = wp_parse_args( $args, $defaults );
    extract( $r, EXTR_SKIP );
    global $page, $numpages, $multipage, $more, $pagenow;
    $output = '';
    if ( $multipage ) {
            if ( $more ) {
                $output .= $before;
                $i = $page + 1;
                if ( $i <= $numpages && $more ) {
                    $output .= _wp_link_page( $i );
                    $output .= $nextpagelink;
                }
                $output .= $after;
            }
    }
    if ( $echo )
    echo $output;
    return $output;
}

This includes the outer element, name etc, I want just the link e.g.

http://domain.com/article/2

Many thanks

5

If you check out the source of _wp_link_page, you'll see all the URL calculations are coded directly within - you can either lift this code straight out into your own function, or sprinkle a little regex around the existing function:

function wpse_204737_get_post_page_url( $i ) {
    if ( preg_match( '/href="([^"]+)"/', _wp_link_page( $i ), $match ) )
        return $match[1];
}

Worth noting that _wp_link_page is a "private" function, and is not intended for use in 3rd party plugins & themes - it may be renamed/removed/deprecated in a subsequent release.

  • Awesome! It's working like a charm :) – mems Oct 21 '15 at 11:24

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.