How can I get my pagination to recognize that it is on the first page?
You should change the first line of your code to: $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; So it sets $paged to 1, when your are on the first page.
You should change the first line of your code to: $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; So it sets $paged to 1, when your are on the first page.
Meta query must be done with a nested array. So it may look more like this: $query = new WP_Query( array( ‘meta_query’ => array( array( ‘key’ => ‘duedate’, ‘value’=> $today, ‘compare’ => ‘>=’, ), ), ‘paged’ => $paged, ‘posts_per_page’=>’20’ ) );
It turns out that in my functions.php file, I had the following function: function limit_posts_per_archive_page() { if ( is_tax(‘project_categories’) ) $limit = 9999; else $limit = get_option(‘posts_per_page’); set_query_var(‘posts_per_archive_page’, $limit); } add_filter(‘pre_get_posts’, ‘limit_posts_per_archive_page’); This was an old function modifying the pagination on the front-end, and it turns out that this was causing the error. Removing the … Read more
This issue I have also faced and suggestion the solution By adding this much javascript to update the pagination links using jquery by adding search in page links. if($(“#listing-tbl”).length) { if($(“#search-search-input”).length) { var search_string = $(“#search-search-input”).val(); if(search_string != “”) { $(“#listing-tbll .pagination-links a”).each(function() { this.href = this.href + “&s=” + search_string; }); } } }
Working code: $display_count = 2; global $wp_query, $paged; $pages = $wp_query->max_num_pages; $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $offset = $page – 1; $showposts = 10; $args = array( ‘showposts’ => 20, ‘post_type’ => ‘any’, ‘post__in’ => $WPIDs, ‘orderby’ => ‘meta_value’, ‘meta_key’ => ‘cf_dimensjon’, ‘order’ => ‘ASC’, ‘number’ => $display_count, ‘paged’ => $paged ); $wp_query … Read more
Your function html5wp_pagination() is using global $wp_query; But you’re using $query = new WP_Query( $args ); Try changing that to $wp_query = new WP_Query( $args ); And adjust the while line so that it uses $wp_query.
Most pagination relies on the $wp_query global. Try changing $loop to $wp_query And put this wp_reset_postdata(); after the endwhile.
query and paginate multiple post types
Using query_posts is generally not recommended. Looking at the Codex, it specifically states: Note: This function isn’t meant to be used by plugins or themes. As explained later, there are better, more performant options to alter the main query. query_posts() is overly simplistic and problematic way to modify main query of a page by replacing … Read more
After trying to ask help from others, I got my solution and here I am sharing that below. First there is no use of ‘in_same_cat’ => false, in upper code and second get_next_post(true);, get_previous_post(true); is used to show next/prev post from current post categories but if you want to show all posts in next/prev then … Read more