Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 10th Oct 2016, 11:54 AM   #1
HyperActive Warrior
 
Join Date: 2008
Posts: 226
Thanks: 1
Thanked 8 Times in 7 Posts
Default
WP Shortcode to implement 'Next Page' link
Share on: 
fb share twitter share gplus share more share

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!

newbie_warrior is offline  
Unread 26th Oct 2016, 04:08 PM   #2
Web Designer
 
Join Date: 2013
Posts: 70
Thanks: 0
Thanked 19 Times in 18 Posts
Default
Re: WP Shortcode to implement 'Next Page' link
Share on: 
fb share twitter share gplus share more share

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' );
Nathan K is offline  
Closed Thread


Bookmarks

Tags
implement, link, page, shortcode


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 10:18 PM.