Advertisement
Fany_VanDaal

Skrytí vybrané kategorie z výpisu

Aug 26th, 2022
1,299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.53 KB | None | 0 0
  1. function get_subcategory_terms( $terms, $taxonomies, $args ) {
  2.     $new_terms  = array();
  3.     $hide_category  = array( 126 ); // ID kategorie, která se má skrýt
  4.    
  5.       // if a product category and on the shop page
  6.     if ( in_array( 'product_cat', $taxonomies ) && !is_admin() && is_shop() ) {
  7.         foreach ( $terms as $key => $term ) {
  8.         if ( ! in_array( $term->term_id, $hide_category ) ) {
  9.             $new_terms[] = $term;
  10.         }
  11.         }
  12.         $terms = $new_terms;
  13.     }
  14.   return $terms;
  15. }
  16. add_filter( 'get_terms', 'get_subcategory_terms', 10, 3 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement