Just unsetting the cat variable probably isn’t enough. The pre_get_posts
hook happens after the query variables have already been parsed. So there’s probably a tax_query with the taxonomy = category and the terms = your category.
You’re already dumping the $query in your code, presumably for debugging. So, look at what you’re actually dumping. Do you see the tax_query? Change your code to adjust that $query to have what you want it to have.
Related Posts:
- How to Modify Taxonomy Archive Page with Search Parameter?
- Formulate a url to show posts with both taxonomy terms
- Display posts from only one post form in custom query and exclude in main query
- Filtering out child category posts from parent category archive not working
- How Can I Change The Tax Query For The Main Loop For Taxonomy Archives?
- Exclude post with taxonomy and from the terms (taxonomy & tag) posts count
- When to use WP_query(), query_posts() and pre_get_posts
- Should I use Pre Get Posts or WP_Query
- Using pre_get_posts with WP_Query
- WP_Query orderby post__in remains ineffective in the Loop [closed]
- What is “main query”? [duplicate]
- WP query taxonomy input differs to output?
- Reduce or prevent calling of update_meta_cache
- How to add taxonomy filter on the query fly?
- Search custom taxonomy term by name
- Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
- How to uniquely identify queries?
- Order Search Results Page by meta_value If no Value Return Remaining Results
- How to display post from current Taxonomy in archive page?
- Archive Listings Filtered by Date Values in a Custom Field/Post Meta?
- pre_get_posts with get_posts
- How-to exclude terms from the main query the most performant way?
- $wp_query initiation?
- Changing Posts Per Page and offset with pre_get_posts
- Display posts the match taxonomy term linked from wp_list_categoies?
- Slow SQL_CALC_FOUND_ROWS Query
- “pre_get_posts” firing on every query
- Why is my WP_Query not working when tax_query terms are an array?
- RSS feed with specific keyword
- Using is_main_query to select custom post type on certain page
- Multiple orderby parameters in pre_get_posts() action
- SQL Statement generated by WP_Query not producing expected results
- Custom archive page based on array of categories and tags
- Move posts to top of WP_Query if in certain Taxonomy?
- Sorting Posts by custom field
- How to pass custom parameter to WP_Query for filtering in pre_get_posts
- Query with pre_get_posts to get pagination
- Querying Multiple Custom Taxonomy Terms
- Recommended way to drop a pending query (in pre_get_posts)?
- Single page theme that uses pages for the content
- WordPress custom search form with pre_get_posts not work
- If orderby parameter using pre_get_posts is the same for multiple posts what fallback does the query use?
- Can not switch the queried post in pre_get_posts hook
- How to target the default Recent Posts and Recent Comments widgets with pre_get_posts?
- Filter and list posts of a custom taxonomy
- order by multiple meta keys in pre_get_posts
- WP Query – Get WooCommerce Products with variation that is in stock
- How to sort posts in admin by titles with dd.mm.yyyy format?
- WP_Tax_Query with post_tag not working
- Filter WordPress posts by between parameter
- Splitting the main query in multiple loops with query_posts and/or pre_get_posts?
- Using pre_get_posts on a specific core/query block
- How to add terms to my tax_query based off of the current post
- Searching through different categories on different pages code is not working
- Filtering posts by custom field value not working
- How to display future posts – modified query still yields 404
- Display link to taxonomy archive only if it has posts with certain custom field values
- pre_get_posts filter meta_query without conflicting existing meta_query
- Including only current user’s posts in search
- When querying a combination of posts and other meta fields, is there a better solution than directly modifying the WHERE value?
- How to change posts order on Category and Tag archives?
- Order taxonomy terms in alphabetical order
- Is it possible to dynamically get queried term AND taxonomy?
- WP Query for variable taxonomies
- How do I search inside specific taxonomies in WordPress
- Pass array of taxonomy terms to wp_query
- Tell wordpress to show a single page instead of an archive
- My Main Query Modification is Messing up my dynamic main – why?
- Offset Page Loops and Pagination
- pre_get_posts Remove tax_query Completely
- pre_get_posts order by not working
- Adding a parameter to the default query
- Using WP_Query in “parse_query” or “pre_get_post” in Posts2Posts
- Taxonomy search/filter with multiple taxonomies and multiple taxonomy terms
- Single meta_query query using OR instead of AND in request’s WHERE statement
- Order by slug in get_terms with multiple taxonomies
- Output an array of terms for a ‘tax_query’ => array()
- How to choose between hooking into per_get_posts or into parse_query
- Function get_queried_object() return NULL in custom taxonomy
- List of the years with posts presented
- Getting Taxonomy inside WP_Query Loop
- Store sticky post’s ids in a transient
- How to change main query based on post meta
- Complex WP_Query (two post types and multiple operators)
- WP_Query Not Recognizing Taxonomy Parameter in Custom Search
- Return Taxonomy/Term Information with Posts (WP_Query/get_posts)
- new WP_Query to get max price meta value not working
- From where is archive.php getting its posts?
- Show Sticky Post at the top but do not show again in the loop?
- WP_Query, pre_get_posts and offset
- Complex WP SQL Query
- Using meta_query with multiple keys and compare values
- Can I set my WP_Query to be a Main Query?
- is_tax() function not working as expected
- Advanced Taxonomy Queries WordPress
- Show scheduled posts in main loop but not in WP_Query?
- Display Featured Post by Categories and Avoid duplicated posts
- Get authors by term id or slug
- WP_Query tax query part of slug
- Taxonomy Query Relation field not behaving correctly?