Hot answers tagged

2

Instead of using the global variables directly, here's a way to use the content_pagination filter to add custom HTML to the last content page: /** * Append HTML to the last content page, if it's paginated */ add_filter( 'content_pagination', function( $pages ) { if( count( $pages ) > 1 ) $pages[count($pages)-1] .= '<div>MY HTML HERE!&...


1

If you mean how to ignore <!--nextpage--> in the feed content, then we can adjust this approach for feeds: /** * Disable content pagination for feeds */ add_filter( 'content_pagination', function( $pages ) { if ( is_feed() ) $pages = [ join( '', (array) $pages ) ]; return $pages; } ); where $pages is an array that contains the ...


1

So the purpose of the function is not that hard: generate a set of URLs of a total size with current page and some pretty parts. The issue is that the way URL is configured is quite... original and documentation doesn't quite describe what happens accurately. The documentation implies that these are default base and format arguments: echo '<pre>', ...


1

Just some additional info for the main comment query: Since you mentioned the global $wp_query object, we can see that it stores: $wp_query->max_num_comment_pages = $comment_query->max_num_pages; in the main comment query in the comments template. There exists a wrapper for this, namely: get_comment_pages_count(); that's available after the ...


1

One approach is to use the cpage query variable: if ( ! empty( get_query_var( 'cpage' ) ) ) { // There is more than one page of comments. }


1

Try this, get_option( 'page_comments' ) will check if pagination is checked in options > discussion, then we compare comments per page (get_query_var( 'comments_per_page' )) to the current post's total comments found (count): function wpse231229_is_paginate_comments( $post_id = 0 ) { return get_option( 'page_comments' ) && ( $pagi = (int) ...


1

I have no doubt that Suyash Jain's solution above is a good one, possibly even the optimal one, and certainly more elegant as a piece of programming than what I am about to propose. However, it strikes me that there is a very simple way to add the desired elements before and after the links produced by `paginate_links: <?php global $wp_query; $big = ...


1

I achieved it through the following code. function wpbeginner_numeric_posts_nav() { echo '<br>'; if( is_singular() ) return; global $wp_query; /** Stop execution if there's only 1 page */ if( $wp_query->max_num_pages <= 1 ) return; $paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) :...



Only top voted, non community-wiki answers of a minimum length are eligible