This seems to be normal behavior since your filter will apply to any query made on post type archive “product”. You might be able to deactivate the filter for search query by adding the is_search condition to your filter so your function would look like so:
add_action('pre_get_posts','shop_filter_cat');
function shop_filter_cat($query) {
if (!is_admin() && is_post_type_archive( 'product' ) && $query->is_main_query() && !is_search()) {
$query->set('tax_query', array(
array ('taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => array( '#','#'), //
)
)
);
}
}
Untested. hopefully this will help !
Codex ref: https://developer.wordpress.org/reference/functions/is_search/
Related Posts:
- Output product category link from WP_Query
- WP_Query To Display Product Of Brand On Taxonomy Page
- Edit tag cloud widget number
- How to automatically apply woocommerce product title to all product images alt tags?
- Build a content and excerpt grid loop with paging and options for # of posts
- retrieve thumbnail from post ID of best selling product in category
- How to get the original price of the product in woocommerce?
- Woocommerce auto cancel On-Hold after X days
- WP_Query | Help me create a search term with an ‘OR’ relation?
- Hide a menu-item and its submenus and display a ‘Log in’ link if the user is logged out
- Using Cookie Data For WP_Query Loop
- WooCommerce – Customer Order History Pagination
- Cleanest/Fastest way to avoid calling and retrieving data from the database multiple times?
- The values of custom fields are not available functions.php
- Why does “get_option” pull in the older value in options.php, rather than the newer value, on submission of a form?
- How to add 2 posts under another post? Formatting should be intact
- WooCommerce – Display variation custom field value [closed]
- Output a WooCommerce product custom field in WooCommerce using get_post_meta()
- Woocommerce: Is it possible to overide the settings for allowing to purchase out of stock products [closed]
- Woocommerce HTML email option unavailable
- How to add SVG icon above product tab title
- Display related products with custom output
- require_once() if a product in woocommerce contains a tag [closed]
- Add product to cart for user – WC()->cart->add_to_cart [closed]
- Remove item in Checkout
- WP_Query | IF within $args array | Help me only add specific arguments if the argument is not blank
- How to display SQL query that ran in WC_Order_Query?
- How do I change this function from two returns to one string to show sku and dimensions in WooCommerce cart?
- woocommerce specific quantities for product
- Personalize checkout text
- CSS change in woo commerce Place Order Text [closed]
- change the default order of posts only for specific categories
- WP All Import / Update stock quantity from multiple XML files
- woocommerce related product title length
- Changing the order of custom fields in the dashboard for Woocommerce variable products [closed]
- Post not populating for custom post type based on category selection
- Custom query vars filters problem with pagination
- WP_Query multiple post results
- WordPress WP_Query without query GET parameters
- How do i wrap woocomerce attribute in list?
- Removing files programmatically
- How to get post category list as select in front-end?
- Custom Taxonomy Select Menu: Setting default option value?
- Displaying Event within two given time frames
- Execute PHP code only with specific user role
- Woocommerce order status payment
- Modify WooCommerce used to get all orders in dashboard
- Let current user know pending posts counts using wp_query
- How to work Woocommerce pagination inside shortcode?
- Isn’t Returning Value While Using SELECT COUNT(*) FROM {$wpdb->prefix}
- WP_Query for woocommerce products with a pattern as a post_title
- “pre_get_posts” orderby custom date field in different format?
- Woocommerce My acount page
- Woocommerce – Exclude variation attribute on specific variation
- How to exclude meta no index pages from wp_list_pages
- Billing detail page doesn’t work after I’ve changed the order of the Woocommerce navigation
- PHP function for horizontal Woocommerce thumbnails and badges
- WP query posts BUT show the most recent and one per author
- Run a sql (update) after 12 hours after the user login. Woocommerce users
- Ajax filter with loadmore button
- php code for outputting a custom page in my account
- Hide specific shipping methode depending on day and time of day
- Programmatically add a product to the cart and set price to zero when buying from certain category
- I want to show cart items number if any or nothing, simple CART text
- Adding custom field to product category and show it to shop/category shop page
- Hide payment method based on user role AND minimum cart value
- posts_per_page displays only 2 posts instead of 4 posts
- WooCommerce display price before add to cart [closed]
- Remove span tags from WooCommerce Downloads page
- Best way to use variables in multiple functions?
- Delete post meta by serialized meta value
- get_filtered_term_product_counts – Get product terms if any products
- Discount in the specific product title using keyword ( Woocoommerce )
- Including user data in “new user notification email”
- Woocommerce – if selected attribute term equals
- split 1 cart item into instock and back ordered
- Adding product permalink on admin order page throwing error
- Add Product Permalink in woocommerce admin order page
- Modify post image in full size
- How to override WooCommerce Order Item Meta with data from Cart?
- Woocommerce textarea format ignored
- How to auto-generate random numbers in username?
- Remove generated category and tag class names from woocommerce product & blog listings markup
- Woocommerce Add custom “Add to cart button” in single page with tags
- Get Billing Email from WooCommece Checkout and Pass to Fullstory JS
- Woocommerce Related Product by 2 taxonomy
- Custom Post type Ajax search results
- Add missing alt tag to featured images for “storefront” theme
- wp_query beginner
- Display text of price (minus 20%) on every product page in a sentence.
- My query keeps looping infinitely ! how to stop it?
- How can I display a query in a page?
- Display Year and Month from custom field + Age Calculator
- insert thumbnail image from php script
- WooCommerce – Print Processing orders [closed]
- Use WP_Query Data In Cookie
- Weird Behaviour: Not all WordPress Posts appearing
- Woocommerce Price Text
- List sibling pages widget, exclude current page
- How to get category pages to look like a certain archive page?