• Hi,

    I have this custom code that I use to hide some categories from displaying to shoppers:

    add_filter( ‘get_terms’, ‘get_subcategory_terms’, 10, 3 );
    function get_subcategory_terms ( $terms, $taxonomies, $args ) {
    $new_terms = array();
    if ( in_array( ‘product_cat’, $taxonomies ) && ! is_admin() && is_shop() ) {
    foreach ( $terms as $key => $term ) {
    if ( ! in_array( $term->slug, array( ‘default’ ) ) ) {
    $new_terms[] = $term;
    }
    }
    $terms = $new_terms;
    }
    return $terms;
    }

    When the code is active together with your plugin, the site crushes on load.

    I have tested on a test site where only this custom code (added with code snippets plugin), your plugin and Woocommerce were active. I’ve also tested with the default Storefront theme and got the same result.

    This code was working with my previous filtering plugin without issue.

    Could you suggest a way to modify the code to work with your plugin.

    Regards.

Viewing 1 replies (of 1 total)
  • Plugin Author RazyRx

    (@razyrx)

    Hello,

    Because $terms variable not always object with some option get_terms return just ids or slug.

    This code must check what $terms variable has.

    Regards,
    Oleg

Viewing 1 replies (of 1 total)
  • The topic ‘Conflict with hide-category custom code’ is closed to new replies.