Hi,
I need to conditionally show/hide specific submenu items. Is there a hook in functions.php I can add where I can do my conditional check?
I figured the easiest way is just add all the menu/submenu items, then in the hook do my check – If true then hide the item, otherwise show the item as normal. I hope that question makes sense.
Thanks in advance for the help.
Hey luismc83,
Thank you for the inquiry.
Instead of adding hooks and programmatically control the visibility of the menu items, you can try one of the following plugins instead.
// https://wordpress.org/plugins/if-menu/
// https://wordpress.org/plugins/conditional-menus/
But if you want to do it manually, try these filters.
// https://developer.wordpress.org/reference/hooks/wp_nav_menu_objects/
// https://developer.wordpress.org/reference/hooks/wp_nav_menu_items
Best regards,
Ismael