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
- 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
- Woocommerce auto cancel On-Hold after X days
- WP_Query | Help me create a search term with an ‘OR’ relation?
- 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?
- WooCommerce – Display variation custom field value [closed]
- 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
- Use is_product_category() properly
- Changing Woocommerce flat rate every nth number of items
- Use wp_get_recent_posts with search term
- Remove query string specific key value
- Limiting woocommerce line_total decimal length
- How do I display a user’s previous orders as a select box option on a product?
- How can I use wp_query to show all product data using just the products ID?
- WooCommerce – Reset quantity input field when variation changes
- Automatically remove a canceled order in Woocommerce
- Two Different Links for Same Product – WooCommerce [closed]
- How can I apply_filters from inside a function?
- Pass Category Name, Description and Photo into variables to pass to jQuery
- Auto-update products after they were published – Woocommerce
- How to prevent WP_Query function from returning all posts when empty?
- Woocommerce related product text
- Woocommerce: hook action/filter I could use to add variation id and price with each attribute opt on WooCommerce Rest api
- Is it possible to intercept all ajax requests and get the parameters and the returns?
- How can I get the values of my WordPress $wpdb query in Jquery?
- Incorrect amount of posts returned when filtering related Woo products by custom taxonomy
- Validation algorithm in checkout field
- Remove echo from shortcode
- Redirect to another page using contact form 7? [closed]
- require_once() if a product in woocommerce contains a tag [closed]
- Add product to cart for user – WC()->cart->add_to_cart [closed]
- WP_Query | IF within $args array | Help me only add specific arguments if the argument is not blank
- 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
- Custom query vars filters problem with pagination
- WordPress WP_Query without query GET parameters
- 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
- Modify WooCommerce used to get all orders in dashboard
- 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
- Woocommerce My acount page
- Woocommerce – Exclude variation attribute on specific variation
- How to exclude meta no index pages from wp_list_pages
- 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
- 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]
- 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 )
- 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 Related Product by 2 taxonomy
- 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?
- 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
- How to get category pages to look like a certain archive page?
- How to get the rating value of each comment
- How to modify this function to exclude also the post belonging to a specific category?
- Setting WooCommerce currency programmatically
- Warning: Attempt to read property “term_id” on int – Woocommerce
- WooCommerce – Show ‘Sales’ badge on variable products where only some variations have sales price [closed]
- posts_clauses drop ACF get_field function
- Hide child of parent categories already hidden with “get_terms_args” – Woocommerce
- Automatically change insurance quantity based on cart total [closed]
- How call WordPress shortcode inside function file
- strict custom php script on specific product category [closed]
- /page/2/ redirect to 404
- Add text below WooCommerce short description if metabox value is true