New answers tagged

0

Why don't you try with default query and use like this if ( get_query_var('paged') ) { $paged = get_query_var('paged'); } elseif ( get_query_var('page') ) { $paged = get_query_var('page'); } else { $paged = 1; } $args = array( 'post_type' => 'post', 'posts_per_page' => 6, 'paged' => $paged, ); query_posts($args); while (...


0

If the posts are being displayed via a static front page (they seem to be?) then you need to use the query parameter page not paged. You could try this: $args2 = array( 'post_type' => 'post', 'posts_per_page' => 6, 'paged' => ( get_query_var('page') ? get_query_var('page') : 1), ); As mentioned on: https://codex.wordpress.org/...


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!&...


0

I had got the ans. First you have to add following code in your function.php to call ajax in your template** add_action( 'wp_ajax_demo-pagination-load-posts', 'cvf_demo_pagination_load_posts' ); add_action( 'wp_ajax_nopriv_demo-pagination-load-posts', 'cvf_demo_pagination_load_posts' ); function cvf_demo_pagination_load_posts() { global $wpdb; /...


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>', ...


-3

I have tried genesis_custom_loop( wp_parse_args($query_args, $args) ); place of wp_reset_query(); . It gives me pagination for my custom template. I don't think you should use below code. // Remove header, navigation, breadcrumbs, footer widgets, footer add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' ); ...


0

You say "However, I know this is not a good way to do this" in your self answer. One thing I could add answering your question and using your answer is, you can use SQL_CALC_FOUND_ROWS with $wpdb $result = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM `wp_table` WHERE 1 LIMIT 10;" ); $total_count = $wpdb->get_var( "SELECT FOUND_ROWS()...


-2

Have you tried paginate_comments_links();? <div class="navigation"> <?php paginate_comments_links(); ?> </div>


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. }


0

All very good thought the simplest way I found was to add a div in the functions.php file that wraps the links. I named mine class="plinks" if ( ! function_exists( 'themename_post_nav' ) ) : function themename_post_nav() { global $post; $previous = ( is_attachment() ) ? get_post( $post->post_parent ) : get_adjacent_post( false, '', true ); $next = ...


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 = ...


0

I stumbled on a same problem and found out that I can replace: 'current' => max( 1, get_query_var('paged') ), with: 'current' => max( 1, get_query_var('page') ), So just renamed 'paged' >'page' in query var and it works.


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' ) ) :...



Top 50 recent answers are included