You can use the pre_get_posts
hook for Woocommerce product query, but here the example is for the main query.
function wpse_306252_query( $query ) {
if($query->is_main_query()) {
$query->set( 'category__not_in', YOUR_CAT_ID);
}
}
add_action( 'pre_get_posts', 'wpse_306252_query' );
If you want the opposite of it, I think the best is to add a SquareExport
parameter to check when you want your products.
function wpse_306252_query( $query ) {
if(!isset($_REQUEST['SquareExport'])) {
$query->set( 'category__not_in', YOUR_CAT_ID);
}
}
add_action( 'pre_get_posts', 'wpse_306252_query' );
The last one will always exclude products from YOUR_CAT_ID
, custom queries, or main query. Hope it fit’s your needs 🙂
Related Posts:
- Show only geolocated user country into Woocommerce checkout country fields
- Reverse engineering of WooCommerce Storefront filters
- How to modify “[Product] has been added to your cart” in WooCommerce?
- WordPress codex: apply_filters – clarification on creating a new hook on the fly. How do we use it?
- Is there a Woocommerce hook that fires when applying a coupon but before checking if it’s valid?
- Filter on a custom product attribute in WooCommerce using meta_query or tax_query [closed]
- Rewriting Woocommerce Product Filters To URL Segments
- What is the action hook for an order that fails on frontend checkout in WooCommerce?
- woocommerce_get_price filter hook not working for product variation price
- Accessing parameters when adding filter
- Using a filter with multiple parameters and $this
- Remove add to cart icon/view product button woocommerce
- Separeting product from post in search result
- Woocommerce get billing state manually
- Redirect customer to login page (with other signup plugin) if user not logged in when proceeding to checkout
- Woocommerce: Complex query in pre_get_posts [closed]
- Using a filter to change a path
- How to apply these filters
- How to add order status class to the body tag?
- Redirect no product url’s to static url
- What Hook/Action is performed when a field in checkout form is changed in WooCommerce
- How can I remove a WooCommerce Product Tab’s sub section in wp-admin?
- How do I create a filter to hide the One Click Accessibility plugin button in WordPress?
- manage_shop_order_posts_custom_column() hook is Not working In Functions.php file in my WordPress active theme
- Display custom product option in admin order details
- How to create a WooCommerce Product filter based on PHP foreach
- Woocommerce : Add name filed of checkout page to buyers wordpress display name
- Two Filter Issue [closed]
- apply_filter and add_filter conflict
- Woocommerce – Hide shipping at all, if only certain product or products with certain shipping class is in the cart
- Running JavaScript after using WooCommerce Filter Plugin
- Redirecting orders by company field
- Combine one action and one filter
- I’m getting error Ultimate WooCommerce Filters
- How to add woocommerce product price filter widget to other page
- How can i add product Accessories from front-end using custom php form?
- How to change lost password email text using custom plugin wordpress?
- Overriding Plugin function in your child theme
- Update / refresh mini cart, after custom AJAX add_to_cart event
- Filter orders in Admin area based on logged in user
- WooCommerce Tax Filter Not Working
- Add suffix to price html does not work
- woocommerce price filter not working when change currency
- With what hook do I remove WooCommerce existing Product Data Tab form fields?
- AffiliateWP not calculating multiple quantities when using affwp_calc_referral_amount filter
- Add second price option based on payment method at cart item price
- How to get the attributes based on dependency in woocommerce?
- Reposition variation stock message
- Add custom ID to WooCommerce product tab
- How to add a new endpoint in woocommerce
- Filter hook before create order WooCommerce
- Get WooCommerce Email Classes in Backend
- Use Hooks to Limit One Comment Per User Per Post – Hide Form if Already Commented
- Woocommerce – Move product without price a the end
- Extra row / text field to a product page (WooCommerce)
- woocommerce_email_attachments filter arguments [closed]
- How to Show Single Product – 4 Data by ID in Custom Page without over-riding the existing Woo-Commerce
- WOOCommerce redirect after registration to account details
- How can I add an additional action button into the woocommerce admin order page?
- Woocommerce Subscriptions – Set Billing Interval/Period
- WooCommerce with ACF: custom fields per product variation
- Woocommerce checkout page reload on up dating shipping method
- change wp_login url and redirect users at the same time
- How to clear woocommerce checkout form after pageload
- Error after woocommerce update from 2.6 to 3.5 [closed]
- Send billing info from woocommerce checkout page to paypal checkout form
- Check if a category has a parent category in WooCommerce REST API
- Remove a higher quantity from stock according to a variation
- Changing a text label into an image
- Custom Price for WooCommerce [closed]
- Is there a preset CSS class when shopping cart isn’t empty?
- How to translate text in function.php with WPML [closed]
- Woocommerce product options [closed]
- WordPress SMS API integration without plugin error
- Display all product tags associated with a specific product category
- Code specific for specific products
- Change Firstname & Lastname order in the order-processing e-mail templates
- Trying to run Javascript on AJAX call
- WooCommerce – dynamically loading checkout page using ajax not showing payment methods for guest
- Show notice to user based on User Meta
- woocommerce ad custom button with custom link after add to cart for every product
- How to fire a disabled WooCommerce New Order notification?
- Set up PayPal with wrong email by mistake
- Does WP-WooC support filters at database?
- How to send welcome email once user buys the subscription
- Removed Sidebar in single product page
- Woocommerce section name? [closed]
- how to change value return by _stock_status
- woocommerce_email_recipient_new_order not triggered
- Load custom post template
- Remove plugin function and add it back in via functions.php
- deactivate product-page image slider on mobile
- Woocommerece category page showing in stock product as out of stock
- Increase product variation limit in woocommerce
- WooCommerce widget “WooCommerce Products” template [closed]
- Woocommerce woocommerce_breadcrumb_defaults filter [closed]
- Use Homepage as “Shop” for Woocommerce [closed]
- How to display India country first in country selection drop down list in WordPress
- Woocommerce | I want to the button ‘Add to Cart’ on the (all) product-page changed by just ‘open product’ button
- Adding line breaks in WooCommerce order processing emails