Is it possible to add a Woocommerce product category to the menu dynamically?
How can I do this? I am trying to add woocommerce product category to the menu dynamically. I am expecting a good solution to this problem. I am Unable to do this.
Question posted in Woocommerce
The official Woocommerce documentation can be found here.
The official Woocommerce documentation can be found here.
2
Answers
There are a few ways to do this using the available WordPress hooks. One such hook you can use is the
wp_nav_menu
filter (see documentation). This hook allows you to directly modify the output of the nav menu HTML. Be careful, as this will affect all menus unless you set a condition based on the args from the 2nd argument in the filter.An example implementation
If you are wanting to place the products in a specific place, you may be better off looking at creating a custom Nav Walker see docs or changing your filter to a more precise spot.
May I have an idea of how do I implement it? I’m very beginner on WP and PHP, that’s the challenge! I’d like to know how may I implement those changes, but not directly to the "CORE" of WP or even the core of Woocommerce plug-in (if it’s that way I’m imagining that it works in general, by the way). In order to, when it had an update, my code wouldn’t be overrided (reset) by the new updated version of the plug-in/wordpress.