WP Get get_query_var(paged) To work on Single Post Templates

add_action( 'template_redirect', function() { if ( is_singular( 'authors' ) ) { global $wp_query; $page = ( int ) $wp_query->get( 'page' ); if ( $page > 1 ) { // convert 'page' to 'paged' $query->set( 'page', 1 ); $query->set( 'paged', $page ); } // prevent redirect remove_action( 'template_redirect', 'redirect_canonical' ); } }, 0 ); // on priority 0 to remove 'redirect_canonical' added with priority 10
Add this to your functions.php

This person give a clear explanation on why query_var(paged) doesn't work on single post templates.
http://wordpress.stackexchange.com/questions/143812/wp-query-pagination-on-single-custom-php/#answer-143837

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.