WP Shortcode to implement 'Next Page' link

1 replies
Any WP programmer experts here know how or where I can find resources to implement
a short code that it will generate an automatic "Next Page" link on a post?

ex. shortcode
[nextpage][/nextpage]

generates:
Next Page >>

current WP site resources are a little complicated for me right now.

Thank you!
#implement #link #page #shortcode
  • Profile picture of the author Nathan K
    You dont need to add the closing tag
    [nextpage]
    To use the title of the post instead of 'Next Page' use
    [nextpage title='true']

    Paste the following codes in functions.php file.

    function shortcode_next_page($atts){
    $a = shortcode_atts( array(
    'title' => 'title',
    ), $atts );

    $next_post = get_next_post();

    if($a['title'] == 'true'){
    if (!empty( $next_post ))
    return '<a href="'. get_permalink( $next_post->ID ) .'">' . $next_post->post_title . ' &raquo;&raquo;</a>';
    }else{
    if (!empty( $next_post ))
    return '<a href="'. get_permalink( $next_post->ID ) .'">Next Page &raquo;&raquo;</a>';
    }
    }

    add_shortcode('nextpage', 'shortcode_next_page' );
    {{ DiscussionBoard.errors[10894749].message }}

Trending Topics