Home › Forums › Basel support forum › Showing wrong result on shop page. › Reply To: Showing wrong result on shop page.
September 14, 2020 at 1:23 pm
#226107
[email protected]
Participant
Thank you so much for all the help!
I really appreciate it. So after extensive testing, it turns out that a specific action within functions.php caused this to happen…
This code messed it up. It is for hiding unwanted categories on the shop page widget.
function get_subcategory_terms( $terms, $taxonomies, $args ) {
$new_terms = array();
$hide_category = array( 29730, 29703, 15, 26287, 26288, 26289, 26290, 26291, 26292, 26293, 26294, 26295, 26308, 26309, 26310, 26311,
26312, 26313, 26315, 26314, 26316, 26317, 26318, 26319, 26327, 26320, 26321, 26322, 26323, 26324, 26325, 26326); // 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() ) {
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 );
Please if you know, maybe you can tell me how to adjust it?