"woocommerce exclude category from loop" Code Answer's
You're definitely familiar with the best coding language Whatever that developers use to develop their projects and they get all their queries like "woocommerce exclude category from loop" answered properly. Developers are finding an appropriate answer about woocommerce exclude category from loop related to the Whatever coding language. By visiting this online portal developers get answers concerning Whatever codes question like woocommerce exclude category from loop. Enter your desired code related query in the search bar and get every piece of information about Whatever code related question on woocommerce exclude category from loop.
woocommerce exclude category from loop
/**
* Exclude products from a particular category on the shop page
*/
function custom_pre_get_posts_query( $q ) {
$tax_query = (array) $q->get( 'tax_query' );
$tax_query[] = array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => array( 'clothing' ), // Don't display products in the clothing category on the shop page.
'operator' => 'NOT IN'
);
$q->set( 'tax_query', $tax_query );
}
add_action( 'woocommerce_product_query', 'custom_pre_get_posts_query' );
Source: docs.woocommerce.com
All those coders who are working on the Whatever based application and are stuck on woocommerce exclude category from loop can get a collection of related answers to their query. Programmers need to enter their query on woocommerce exclude category from loop related to Whatever code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about woocommerce exclude category from loop for the programmers working on Whatever code while coding their module. Coders are also allowed to rectify already present answers of woocommerce exclude category from loop while working on the Whatever language code. Developers can add up suggestions if they deem fit any other answer relating to "woocommerce exclude category from loop". Visit this developer's friendly online web community, CodeProZone, and get your queries like woocommerce exclude category from loop resolved professionally and stay updated to the latest Whatever updates.