Home Forums WoodMart support forum Hide categories from category loop

Hide categories from category loop

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #686784

    hofitd
    Participant

    Hi
    I use the Product Categories Elementor element to show the categories.
    I have some categories that I need to hide or show manually.

    The best way for me to achieve it, is to add an ACF field to the category edit page, so that the website owner can click this button to decide if hw wants to show or to hide this category.

    The problem is – that the categories loop code doesn’t contain any data on the specific categoty – such as term id, slug or special css classes I want to add.

    How can I add a special class to the loop element based on the selected value of the acf field?
    these are the exiting classes:
    wd-col category-grid-item wd-cat cat-design-alt without-product-count wd-with-subcat product-category product

    Thank you
    Hofit

    #687074

    Hung Pham
    Participant

    Hi hofitd,

    Thanks for reaching to us and appreciate your patience.

    You can use Custom CSS to hide specific categories by using the ID, let me know your decision.

    Regards,
    Hung PD

    #687375

    hofitd
    Participant

    Hello
    there is no ID in the code.
    see attached screenshot.

    Attachments:
    You must be logged in to view attached files.
    #687440

    Hung Pham
    Participant

    Hi hofitd,

    Thanks for your patience.

    You can use data-loop attr, for e.x:

    .wd-cats .product-category[data-loop="11"]{
        display: none;
    }

    Regards,
    Hung PD

    #688026

    hofitd
    Participant

    Hi
    data loop is the order of the items on the page, so in case I will change the categories order – it will hide categories that should be displayed, just becuase the order is changed.
    I can’t use this solution or any byilt-in solution. This is why I contacted you, since there is no unique ID or class to any of the elements.

    What I need is a manual ability to hide and show specific categories (by using ACF field).
    Can you please let me know how can I use any kind of hook in my child theme’s functions.php file, to add a unique css class to the category item ?

    Thank you
    Hofit

    #688126

    Hung Pham
    Participant

    Hi hofitd,

    Unfortunately, you requests require customization and out of our basic support. Thanks for understanding our limitations.

    Regards,
    Hung PD

    #688131

    hofitd
    Participant

    Hi
    I am not asking you to do any customization work.
    I only ask if you have a hook for categories element I can use to add a custom class, that’s all.
    It will save me a lot of time if a hook like this already exists.

    Thanks

    #688655

    Hung Pham
    Participant

    Hi hofitd,

    Thanks for your patience.

    WooCommerce provides a hook for this. You can use the product_cat_class filter to add your own custom class to category elements. Here are some references that explain how to do it:

    https://wp-kama.com/plugin/woocommerce/hook/product_cat_class
    https://stackoverflow.com/questions/55405633/add-a-class-to-the-category-list-items-on-woocommerce-shop-page

    Regards,
    Hung PD

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