• Resolved jetcrusher

    (@jetcrusher)


    My products are assigned to two categories as in Root -> Child

    I want the sidebar product menu to always highlight the Child category. Is there an action I can intercept, and override, to modify what gets selected as active and highlighted? I’ve been able to find one for the main menu, nav_menu_css_class, but can’t seem to locate what does the sidebar product categories menu.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support shahzeen(woo-hc)

    (@shahzeenfarooq)

    Hi there!

    Thanks for explaining your goal! Before we go further, could you clarify which block or widget you’re using to display the sidebar product menu? Could you also please share the shop page URL where you want to highlight the active child category?

    In the meantime, you can use the Category List block, then select Taxonomy → Product Categories from the right sidebar, as shown in these screenshots:

    Note: Do not use the older Product Categories widget. Instead, use the Category List block and set the taxonomy to Product Categories as shown above.

    When you use the Category List block, WooCommerce automatically adds the class current-cat to the active category. You can target this class with CSS to change the color or otherwise highlight the active child category.

    I hope this helps.


    Thread Starter jetcrusher

    (@jetcrusher)

    Thank you for the reply.

    So I’m using the Flatsome theme and the “Shop Sidebar” uses Product Categories widget.

    I didn’t explain the category structure correctly. Technically I’m not using Parent -> Child configuration. I have 2 global categories, each product is always assigned to one of those. If we use car analogy, think of it as “All Toyota” and “All Ford”. Then, I have more descriptive categories, eg. Body, Suspension, Electrical. If a product is added to “All Toyota” and Electrical, I want the the Electrical menu to be the active one, not “All Toyota”.

    I was able to get this to work for the breadcrumbs using a hook but I can’t figure out how to intercept the data which generates the sidebar widget menu.

    (Creating a true Parent -> Child category setup is not an option, there aren’t enough products)

    Plugin Support Frank Remmy (woo-hc)

    (@frankremmy)

    Hi @jetcrusher,

    Thanks for the clarification! I understand you want to prioritize the more descriptive categories (like “Electrical”) over the brand categories (“All Toyota”, “All Ford”) in your sidebar widget highlighting.

    Since you’re working with the Flatsome theme’s Product Categories widget and need to intercept the data that determines which category gets highlighted, this involves custom code modifications that are outside our Support Policy.

    That said, I would suggest:

    • Overriding the default Product Categories widget output via custom code (e.g., by extending WP_Widget_Categories or hooking into the widget output). In your custom logic, dynamically detect the current product’s assigned categories, prioritize your descriptive categories (“Body,” “Suspension,” “Electrical”), and then add the current-cat class to those in the sidebar markup instead of the global ones.
    • Consider switching to the Category List block in a sidebar widget area (if your theme supports block-based sidebars or widget areas). The block gives more flexibility and can be targeted via hooks or filters to customize active categories.

    If you’re open to custom development, I would recommend our WooExperts and Codeable.io as options for getting professional help. Alternatively, you can also ask your development questions in the WooCommerce Community Slack.

    I hope that helps. Let us know if you need anything else.

    Plugin Support thelmachido a11n

    (@thelmachido)

    It’s been a while since we heard back from you for this reason we are closing this thread. 

    If WooCommerce has been useful for your store and you appreciate the support you’ve received, we’d truly appreciate it if you could leave us a quick review here: 

     https://ww.wp.xz.cn/support/plugin/woocommerce/reviews/#new-post

    Feel free to open a new forum topic if you run into any other problem. 

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

You must be logged in to reply to this topic.