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
- Woocommerce add extra field to variation product
- How to execute a javascript function just before saving a woocommerce post or a post?
- Change Meta Title seperator and remove on homepage
- Shortcode with product catgory counter
- Woocommerce 2.5.5 get billing email from order instance
- Woocommerce products are not displayed on front-end . No products were found matching your selection [closed]
- Custom Text on Product Page based on Shipping Class [closed]
- How to set a minimum length for username in Woocommerce? [closed]
- How to get term name with link for specific ids
- WooCommerce Product Page css
- Programatically Remove Item from Cart Not Working – Needs Page Refresh
- Set default value field meta_Value [closed]
- remove default pagination on woocommerce shop page
- Woocommerce Login Redirect to old domain
- Images not uploading on product page of woocommercr
- How to access WC()->cart in CF7 hook wpcf7_special_mail_tags
- How to integrate e-transfers with checkout in WooCommerce
- Send all emails to Shop Manager along with admin
- Snippet to copy product affiliate link to a custom field
- Wrong Billing Information in WC_Checkout->get_checkout_fields(‘billing’)?
- How to display two different custom taxonomy terms on a WooCommerce single product page
- Registration roles
- Change password notification email
- how can my customers view their purchased products history like an invoice in a specific page on WordPress
- How do I make my products on the homepage responsive?
- How to customize product at cart page
- WooCommerce Storefront site-header padding
- How to get woocommerce integration instance?
- Create woocommerce order on new user registration
- How to put a date range in a virtual/downloadable product? [closed]
- Redirect whole website or pages to /wp-admin in wordpress
- Changing sale price programmatically, but it’s not shown on front-end
- Can I remove WooCommerce specific product categories from shop managers?
- Fetch products with filter by similar categories at same time
- Trying query woocommerce product order by menu order and stock status
- editing product page template – getting template for related products not working
- 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
- Create WordPress account on different domain when WooCommerce order completed
- Creating a woocommerce order when a user creates an account
- Disable Woocommerce Block Editor
- Woocommerce backend sorting product drag drop by menu_order to date
- I want to update shipping charge $0 for all Woocommeerce Subscription auto-renewal orders
- Conflict between Woocommerce Booking + Woocommerce Product Options [closed]
- Save customer email via WPForms on checkbox marking when placing the Woocommerce order
- Fatal error: Uncaught Error: The script tried to modify a property on an incomplete object
- Cannot use dynamic prefix for WooCommerce permalink
- Woocommerce paginate link generates #038 instead of ? – seems connected to caching
- Searching in categories AND custom fields
- How to detect changes in WooCommerce store (react)?
- Issues with WooCommerce: jquery.blockUI.min.js