New Landing How can we help? Atelier Hide / Exclude specific "posted_in" category on product listing

Viewing 4 posts - 1 through 4 (of 4 total)
  • Posted in: Atelier
  • #204333
    ecrotty
    Member
    Post count: 25

    Is it possible to somehow hook (if that’s the best way) lines in the templates that look like this :

    echo $product->get_categories( ‘, ‘, ‘<h5 class=”posted_in”>’, ‘</h5>’ );

    I’d like to exclude / hide a specific category when executing a product loop and displaying a product on any page.

    However, I’d like to continue showing the category in the woocommerce product categories widget.

    To help the conversation, assume the category is “Free” and the ID is 165.

    I’d like to see if this approach exists rather than modifying the templates direct.

    Thanks!

    #204419
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    I am not sure but you can try this code.

    <?php 
    add_filter( 'woocommerce_product_categories_widget_dropdown_args', 'rv_exclude_wc_widget_categories' );
    add_filter( 'woocommerce_product_categories_widget_args', 'rv_exclude_wc_widget_categories' );
    function rv_exclude_wc_widget_categories( $cat_args ) {
    	$cat_args['exclude'] = array('55','68'); // Insert the product category IDs you wish to exclude
    	return $cat_args;
    }
    ?>

    Thanks
    Mohammad

    #204644
    ecrotty
    Member
    Post count: 25

    That’s what I was able to come up with as well and that does remove it from the widget … but not the category / tag for the individual product itself.

    I’ll see what else I can find.

    Thanks!

    #204691
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Its ok 🙂 .
    Thanks
    Mohammad

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in and have valid license to reply to this topic.

License required for the following item
Login and Registration Log in · Register