I have certain menus load on posts in particular categories. For example, in my wordpress menus I’ll have a Cars & Trucks menu that I want to appear on posts in the Cars and Trucks categories. I do this by putting conditionals in my single.php that load the correct menu.
But if I add new menus and categories, the single.php has to be re-written. I’d like to have a relational field that associates a menu with a category term. Is it possible?
There is an addon plugin that I use regularly for allowing clients to add menus. https://wordpress.org/plugins/advanced-custom-fields-nav-menu-field/
Hi @hube2 @photocurio !
Do you plan to add this into core for that ? The plugin you mentioned has not been updated for 4 years…
Thank you in advance !
Sorry, neither of us are ACF devs. You’d have to ask that of the dev team. https://www.advancedcustomfields.com/contact/
I haven’t actually used that plugin in a while, this was posted a long time ago. When I want to do this now I just use a select field that is dynamically populated with choices for menus that have been created (https://www.advancedcustomfields.com/resources/dynamically-populate-a-select-fields-choices/). I then code the template to show the selected menu using standard WP functions. The reason for this is so that I can do custom work that the plugin could not handle and the second reason is that I don’t like being dependent on 3rd party addons for ACF because of this very reason, you never know when the dev will stop supporting them.
I’m not sure why I was trying to include a menu that way when I posted, but if I was doing it now I would:
- Add a plugin that lets me assign a specific sidebar to a page or taxonomy term.
- Put my menu in a widget in that sidebar.