SOLVED: Offset categories

Hello,
I have products that have 2 categories. I would like to offset the last category and only display one, also if possible offset a specific category.

Kind regards

Hello @intovortex

You may use the WordPress hook described here to remove the unwanted category terms from that list.

Cheers
Luis

1 Like

in case anyone needs it, here is a code snippet I created

add_filter( ‘get_terms’, ‘my_offset_term’, 10, 3 );
function my_offset_term( $terms, $taxonomies, $args ) {
if ( in_array( ‘product_cat’, $taxonomies ) ) {
foreach ( $terms as $key => $term ) {
if ( $term->term_id == 16 ) {
unset( $terms[$key] );
}
}
}
return $terms;
}

replace the term_id==16 with your own term id

1 Like

Thank you for helping me in the right direction,

cheers