![]() |
WP Shortcode to implement 'Next Page' link 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! |
Re: WP Shortcode to implement 'Next Page' link 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 . ' »»</a>'; }else{ if (!empty( $next_post )) return '<a href="'. get_permalink( $next_post->ID ) .'">Next Page »»</a>'; } } add_shortcode('nextpage', 'shortcode_next_page' ); |
| All times are GMT -6. The time now is 10:29 PM. |