New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for custom fields in navigation menus #766
Comments
|
Could someone enlighten me on some usecases for this type of thing? I won't say I'm going to close and outright reject the idea, but I could use some more context. It has me wondering if maybe an options page would work for the storing of the values, and then simply providing some documentation on how to potentially hook into the navigation menu system. |
|
@tw2113 It's a 2 year old feature request so I'm trying to recall why I created this feature request. I believe it was to have the ability to a add icon-picker to navigation items. Other usecases it could be for creating a better user experience for creating navigations where users can customize colors, add extra text, etc. to navigation items without having to know which specific css classes to add in the existing "CSS-classes" field. Looking at the existing navigation builder I can see it would 2 places where custom fields could be added. Custom fields to navigation items and new fields to the navigation settings. With that said I don't think I've needed this functionality since I created this feature request, and by looking at others interest in this I think it's safe to say it's not something developers need to solve very often. |
|
@tw2113 Funny enough I was in the same situation today. So I started looking into how I could implement custom fields into navigation menus based on this blog post.. While researching I found someone have already made an implementation using CMB2 in navigation items.. Out of the box I had problems with using this as a plugin, but after loading it into my theme using a PSR-4 autoloader I got it to work (the plugin is probably meant to be loaded with composer). @marsjaninzmarsa I see you have liked my proposal, you will probably find this interesting. |
|
Definitely a more composer-focused version. Not immediately sure where those CMB2 namespaces are coming from, unless I'm missing information/details. However, if it works, more power to it all. |
|
Nah, it's saving data in options table, why? Menu items are just posts, we can use postmeta. |
|
Opened issue: nsrosenqvist/cmb2-nav-menus#1. |
|
Just $0.02 here, another use-case could be adding icons to nav menu items. There is already a contributed CMB2 field type for fontawesome icons. What I am not sure of yet is whether CMB2 Nav Menus works without composer. I'll try to give it a test run soon, but for my use-case, I'd need it to work without composer. |
|
Is there still a need for this? Wordpress added aditional hooks in 5.4 that would make it much easier to integrate: https://make.wordpress.org/core/2020/02/25/wordpress-5-4-introduces-new-hooks-to-add-custom-fields-to-menu-items/ I often have the need to add icons or other additional data to menu items. As a proof of concept, I've now added nav_menu_item as an object_type to see if it was easily possible. It is. Is this something we could include @jtsternberg? I could provide a PR with some additional work. |
|
A PR sounds intriguing, and I'd definitely check it out, but I can't promise it's something I'd want to add to CMB2 core to support. I guess it depends on how much complexity is added vs the gain. |
|
I just so happened to have a need for this. And I am a bit struggling tbh with this. @fabianpimminger can I maybe reach out to you for help? |
|
Hey! Just came across this. I really need to add an image field to menu items and can't find anything on the web on how do do it. Can someone post a gist with a basic example please? I think there are many people that would find it helpful. |
|
It is really important for CMB2 users to include also 'object_types' => array('nav_menu_item') I am working in a custom project and client need for each item menu to add differnet icon image, so cmb2 is not supporting it. |
Feature request.
CMB2 works really well with users and terms, what about adding the same awesomeness to navigation menus?
The text was updated successfully, but these errors were encountered: