- This topic has 11 replies, 3 voices, and was last updated 3 years, 10 months ago by Tom.
June 14, 2017 at 11:08 am #333584Jay Martin
I have a situation in which I have to create a menu tree (a single menu item in the Primary Nav menu) that comprises a total of 40 submenu items in 3 layers.
Almost all of the 40 submenu items have simple, regular productions, making it ideal (and simple) to dynamically generate the set.
Creating 40 menu items using the standard WP Menu tool would be most laborious. Is there a simple way to generate a menu tree such that it automagically works with all the various forms of menus (site-navigation, sticky-*, mobile, etc)?
If I have somehow overlooked some obvious documentation, I apologize, and please point me to it.
Thanks.GeneratePress 1.3.48GP Premium 1.3June 14, 2017 at 11:52 am #333603LeoStaffCustomer Support
I’m not quite sure what you mean? Like a function that creates the menu structure for you automatically?
If that’s the case I don’t think so…
If you want all the menus to be the same then you should only have to create the menu once and set it to Primary and Slideout in Theme Locations.
Let me know if I’m misunderstanding something.June 14, 2017 at 12:06 pm #333610Jay Martin
Again, I have 40 menu items under one top-level menu item to create. Many of these menu items require backend processing (ie, they’re not simple page/post links, nor simple URLs), but are easily produced using simple production rules in most cases.
Using the Menu tool, besides being incredibly laborious, requires the use of shortcode support (I use the “Shortcodes in Menus” plugin). I was hoping to improve performance and make life much simpler by just creating the menu tree on the fly, then adding it to various menu locations.
I have done considerable reverse-engineering on the form and structure of the menus generated by GP for the main site-navigation menu, but I am concerned about the other menus involved, such as the sticky menus and the mobile version.
So, I am looking for a way to hook into GP’s menu construction mechanism to ensure my menu tree is properly inserted (and rendered viz CSS) in all the related menus.
WP has quite a nice open API for adding things to the Admin Toolbar menu, and I was hoping GP had something similar, although I am fully aware that a typical Theme’s menu construction rules are necessarily more complex owing to the fact that several incarnations of a given menu item are placed in various menus (again, the sticky menus, the mobile menu, etc).
Am I asking for too much here?June 14, 2017 at 12:15 pm #333620LeoStaffCustomer SupportJune 14, 2017 at 12:16 pm #333622Jay Martin
Thanks. I don’t want to “push” you fine folks, but I need to get rolling on this task, but would rather wait until I hear back from the developers before I launch off into additional reverse-engineering to see if I can hook into the Theme or not.
Thanks, Leo.June 14, 2017 at 6:54 pm #333752TomLead DeveloperLead Developer
GP just uses the WP menu construction, so there’s no real way to do this that’s GP specific.
As far as I know, the only way to automatically add pages is the “Automatically add new top-level pages to this menu” option, but as that says, it should only take care of top-level pages.
Another option is keeping the theme location un-set, which will then display ALL pages on your site, and show the sub-menus based on the page parent connection. Again, not really ideal.June 14, 2017 at 6:59 pm #333755Jay Martin
So are you saying that GP doesn’t do anything special in terms of constructing the physical menus based on the menu definitions and prescribed locations, that GP delegates all menu construction to the core WP?June 14, 2017 at 7:05 pm #333764TomLead DeveloperLead Developer
It depends what you mean by construction. GP sets the HTML classes/IDs of the container, but the actual structure of the menu items is all WP.June 14, 2017 at 8:00 pm #333776Jay Martin
Can you save me some time reverse-engineering the code and perhaps point me to where said construction is performed in the GP code base?
Thanks.June 14, 2017 at 8:05 pm #333778TomLead DeveloperLead DeveloperJune 15, 2017 at 5:25 am #333933Jay Martin
Thanks for the pointer, Tom.
So if I understand you correctly, GeneratePress does not in any way get involved with the definition and construction of the actual menu items, instead letting stock WordPress handle it. GP may handle such things as sticky menus and various rendering (CSS) attributes (based on the user’s settings in the Customizer), but that’s about it.
At this point I’m going to mark this topic as “Resolved”, but I may come back later and add any info I find useful to this discussion, for posterity’s sake, especially if I can find a way to cleanly export/import Menus in a safe and effective manner.
As always, I appreciate your exceptionally rapid response. Thanks!June 15, 2017 at 11:00 am #334070TomLead DeveloperLead Developer
That’s correct. Things like the sticky menu etc.. just attach to the class given to the main navigation element.
No problem! 🙂
- You must be logged in to reply to this topic.