next_posts_link() always generates second page link on custom post type
use this: get_query_var(‘paged’) instead of get_query_var(‘page’) $paged = get_query_var( ‘paged’ ) ? get_query_var( ‘paged’ ) : 1; hope this will help!
use this: get_query_var(‘paged’) instead of get_query_var(‘page’) $paged = get_query_var( ‘paged’ ) ? get_query_var( ‘paged’ ) : 1; hope this will help!
query_posts should never be used. Right now you are getting pagination urls that are relevent to whatever you feed to the query_posts but they lack the url of the page. In general, regardless of the query_posts issue, pagination in internal loops should use pagination parameters which are different than those used by wordpress core, or … Read more
Thank you for your help – I have found the offending function. The plugin is meant to manage about 400,000 case files and provide a fast search. In order to manage the search on the front-end of the site, I need to manipulate the number of results found for any given search, so I added … Read more
Check the function which outputs pagination. It could look like this: <?php the_posts_pagination( array( ‘mid_size’ => 2, ‘prev_text’ => __( ‘Prev’, ‘textdomain’ ), ‘next_text’ => __( ‘Next’, ‘textdomain’ ), ) ); ?> You need to change mid_size parameter. This parameter determines how many page numbers to display to either side of the current page. So … Read more
You can try: $number = $counter + ( $current_page – 1 ) * $users_per_page; with your increasing $counter variable in the loop. Here we assume $counter >= 0, $current_page >= 1 and $users_per_page >= 1. We might combine it into: $number = ++$counter + ( $current_page – 1 ) * $users_per_page; with $counter = 0 … Read more
control posts order by select option
So it looks like you can’t get the page number unless you query the whole post type and query strings and then check that against how many pages you show on each page and then do some math to find what page that will be on, so I stuck with the next best thing. I … Read more
Ok, I found the solution for this specific case, since it’s a template for the articles. On the admin settings, define the custom page as the page for the articles. And using the code I posted in the question, everything works just fine. Now, if you are using a page for the homepage, another for … Read more
You shouldn’t be using a custom query for a post type archive page. Pagination being difficult is one of the reasons. If you want to change your post type archive to sort by a custom field, hook into pre_get_posts to modify the main query: function wpse_282839_post_type_order( $query ) { if ( ! is_admin() && $query->is_post_type_archive( … Read more
pagination functions are not working