Fany_VanDaal icon

Skrytí vybrané kategorie z výpisu

Fany_VanDaal | PRO | 08/26/22 10:40:33 AM UTC | 0 ⭐ | 1602 👁️ | Never ⏰ | []
PHP |

530 B

|

None

|

0 👍

/

0 👎

function get_subcategory_terms( $terms, $taxonomies, $args ) { 
    $new_terms  = array();
    $hide_category  = array( 126 ); // ID kategorie, která se má skrýt
    
      // 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 );

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎