Don’t stomp on the $wp_query
global. Use your own variable to hold your query instead:
$custom_query = new WP_Query( $args );
Then, you can use a little trick to fix pagination. Do this before the loop:
global $wp_query;
// Store it for safekeeping
$temp_wp_query = $wp_query;
// Now blank it out
$wp_query = null;
// Now populate it with your custom query
$wp_query = $custom_query;
Then, after the loop closes, restore the original query object:
$wp_query = $temp_wp_query;
Now, your pagination should work properly.
Related Posts:
- Custom Taxonomy not working with posts_per_page in new WP_query (pagination problem)
- Using wp_query is it possible to orderby taxonomy?
- “tax_query” parameter not working with WP_Query
- How do I exclude a custom taxonomy from the post loop
- Custom Taxonomy Endpoint Pagination using paginate_links()
- Custom Taxonomy and Tax_Query
- Using WordPress to make a “Product Search” type navigation drilldown
- display posts with same taxonomy term
- get_query_var(‘paged’) always returns empty
- Including all terms in wordpress tax_query
- How to get first post in a category of a custom taxonomy
- Display one post from each term in a custom taxonomy [closed]
- Using tax_query creates a 1 = 0 or 1 = 1 in $wp_query->request
- search query within custom taxonomy term, post title and meta field
- How to pass posts_per_page and paged params query vars to custom taxonomy archive urls?
- wp query with multiple taxonomy?
- wp_query orderby title and meta key value (WP3.1)
- On Taxonomy Template page, want to add Post_Type
- Page queried instead of a custom taxonomy
- Custom WP_Query breaks default behaviour of viewing right post associated with tax-term!
- The next_posts_link() show me a aditional page in blank
- Custom Taxonomy terms with latest post ordered by date pagination issue
- custom post type paging not working past page 3
- Help with a query not working with custom taxonomy
- Listing child terms of parent term
- Adding session variable and/or cookie based on user-selected input
- Taxonomy page lead to 404 page on pagination
- Excluding a custom taxonomy term breaks wp_get_post_terms
- Advanced Tax Query
- why do drafts return as part of wp_query?
- Improving WP_Query performance for multiple taxonomies
- Remove pagination from WooCommerce product categories on admin edit navigation menus
- WP Query with custom taxonomy
- how to search in custom fields & custom taxonomy for custom search
- WP_Query on custom taxonomy works fine but fails if run through wp_ajax_
- Advanced Query Logic With Multiple Taxonomies
- How do I Use Multiple Loops with WP_Query?
- cannot get multiple loops using tax_query
- Pagination : How to remove /page/x/ after a ‘POST’ action on a form returning to page 1
- Pagination for Custom Taxonomy Page [duplicate]
- Display all posts for taxonomy term across multiple custom post types
- Selecting all posts from the children of a particular parent taxonomy
- Pagination on custom taxonomy
- Custom taxonomy rewrite give pagination 404
- How to create pagination for custom taxonomy in WordPress
- Taxonomy Pagination Rewrite
- problem in taxonomy-{taxonomy}.php pagination
- Sorting Custom Posts on Archive page with pagination
- Hiding taxonomies with no children WP_Query & tax_query
- Can I use OR relation for one item when calling tax_query from WP_Query and use AND for the rest?
- Set tax_query conditionally with new WP_Query
- querying posts by custom taxonomy terms right from a querystring based URL
- Custom taxonomy pagination
- Query custom taxonomy by term id?
- When filtering query on custom taxonomy; main menu dissapears
- Exclude taxonomy term from all loops, but having it on widget
- Why can’t I use an array of term slugs in WP_Query?
- wp_query not resetting, last post hanging
- Using WP_Query and Query_post for the loop?
- How to do a particular wp_query taxonomy search
- How can I change the output display of my pagination?
- How can I get a paginated list of custom taxonomy tags with posts?
- Custom post type and custom taxonomy 404 on page 2
- pagination not working on custom-taxonomy template
- Wp_query…a type of term a different div
- check if a taxnomy queried in $wp_query?
- Taxonomy.php how to show post only in current taxonomy with wp_query?
- WP_Query tax_query – Show results if child has parent X
- Query custom taxonomy for category including children
- Proper way to create taxonomy queries
- how to use tax_query to apply both terms or one if one is empty
- Get current page term title to use in WP_Query
- passing moree than one value of slugs in taxonomy using variable
- custom taxonomy pagination 404 error
- Why is my pagination /page/2 taking me to index.php?
- Keeping session instance of random display results over pagination breaks
- add pagination in wordpress page template
- How to pass posts_per_page and paged params query vars to custom taxonomy archive urls?
- Pagination for Custom Taxonomy
- pagination for list category posts ( Custom post type )
- Error 404 in Custom taxonomy with pagination
- How do you move custom fields to custom taxonomies using WP Queries
- WordPress hiding posts without content on custom taxonomy query. How to solve?
- Run next query based on first query’s term
- Get the original menu item name string instead of the label
- How to use tax_query other than by slug or id or solve custom taxonomy tags conflicts with pre-existing tags?
- Pagination with custom query (not using posts)
- Order posts with custom taxonomy array
- Getting grandchildren of a post with a specified custom taxonomy?
- Taxonomy Parameters in WP Query to get posts from two different taxonomies
- Custom Taxonomy + JQuery Tabs
- Advanced AND tax_query in sidebar with 2 taxonomies
- How to query posts that are not related to any term of a taxonomy?
- Using wp_query is it possible to orderby taxonomy?
- How to limit posts to 1 from each term with tax_query?
- query posts returns 10 records
- add_rewrite_rule pagination 404 error on page 4 and above
- Pagination links not working for custom taxonomy
- Loop posts without any taxonomy
- taxonomy-{term}.php terms pagination returning 404 after a certain page