Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

Hide Product Category on

$
0
0

Replies: 1

Hi – I have used the code below to remove the ‘ACB’ product category on https://artchilli.com/gallery/. That works fine, however the ‘ACB’ product category still shows on the product category & tag pages e.g. https://artchilli.com/product-category/paintings/ & https://artchilli.com/product-tag/abstract/. How do I remove it from these pages?

/**
* Show products only of selected category.
*/
function get_subcategory_terms( $terms, $taxonomies, $args ) {

$new_terms = array();
$hide_category = array( 131 ); // Ids of the category you don’t want to display on the shop page

// if a product category and on the shop page
if ( in_array( ‘product_cat’, $taxonomies ) && !is_admin() && is_shop() ) {

foreach ( $terms as $key => $term ) {

if ( ! in_array( $term->term_id, $hide_category ) ) {
$new_terms[] = $term;
}
}
$terms = $new_terms;
}
return $terms;
}
add_filter( ‘get_terms’, ‘get_subcategory_terms’, 10, 3 );


Viewing all articles
Browse latest Browse all 59525

Trending Articles