Navception: The act of embedding a pre-constructed WordPress Menu inside another WordPress Menu.
Navception adds a simple feature to WordPress Menus, but opens the door to powerful possibilities. New to your WordPress Nav Menu editor, is a box that lets you add menus into your menus! This allows you to create one menu to include as a submenu once in another menu, multiple times in another menu, or multiple times in multiple menus. What makes this so powerful is that if you decide that your submenu needs another link added to it, you only have to update it in one place! Navception, a simple concept with powerful results!
Let’s look at a couple of scenarios:
- If you have a submenu you need repeated across your site: First you have to add all the links everywhere you want the submenu, then to update the submenu you have to modify the links everywhere the submenu exists.
- If you have too many menu items in your menu: You have to pick and choose which menu items are removed to make room for new ones.
- If you have a submenu you need repeated across your site: First you create the submenu as a stand-alone WordPress menu and embed it where you need it once, then to update the submenu you only need to modify the links in the stand-alone menu.
- If you have too many menu items in your menu: You make some of the submenus separate WordPress menus and embed those new menus into the original menu to make room for more menu items.
Navception became a thought when working on a client’s main menu. This menu was a typical 3 level menu, with two submenus that were repeated 4 times each. Those submenus were a hassle to add and a pain to maintain. When I realized that I wanted a plugin that allowed me to create a submenu once and include it as a menu item in a separate menu, I was surprised to find that no such plugin existed.
Navception became a necessity when working on that same client’s main menu. This menu became so large that I received the following warning: “You are approaching the post variable limit imposed by your server configuration. Exceeding this limit may automatically delete menu items when you save.” It turns out that every Nav Menu Item in the WordPress Admin area has roughly 8 inputs associated with it. One of the aforementioned submenus contained 7 menu items, or 56 inputs. Using Navception, I created that submenu as a stand-alone WordPress menu, then included it as 1 menu item in the client’s main menu. This reduced the inputs generated by that submenu from 56 to 8. Since that submenu was included 4 times, I not only avoided the Post Variable Limit, but I also made the menu easier to manage.
Dangers of Navception
When embedding menus in other menus, you must take care not to include the same menu in itself. When done directly or indirectly, this can cause your website to go into an infinite loop (aka Limbo) when attempting to display the menu. I added some safeguards to keep you from accidentally causing this to happen, though I’m only 90% confident that I covered all scenarios. If you ever put your website into Limbo, you only need to remove the menu you embedded, then please make a post in the support forum telling me what you did so I can cover that case as well.
You install Navception like you would any other basic plugin. For details read the WordPress documentation on installing plugins
- Why don’t I see the Nav Menu Menu Items in the Menu Editor?
WordPress might have the Nav Menu options hidden after activation. To fix this, go to the menu editor, click the “Screen Options” button, then make sure the checkbox next to “Navigation Menus” is checked.
བྱས་རྗེས་འཇོག་མཁན། & གསར་འབྱེད་པ།
“Navception” is open source software. The following people have contributed to this plugin.བྱས་རྗེས་འཇོག་མཁན།
Interested in development?
- Rewrote the main Navception code to run on the ‘wp_get_nav_menu_items’ filter, which is easier to code and allows any custom Nav Menu Walker to do its thing. I believe this also makes Navception work with Nav Menu Roles.
- Rewriting the main Navception code also fixes a bug where the ‘menu-item-has-children’ class wouldn’t be added to menu items in a navcepted menu (Thanks to Emma for reporting :D)
- Removed the need to include wp-admin/includes/nav-menu.php by replacing the use of the ‘nav_menu_meta_box_object’ filter with a custom ‘navception_nav_menu_meta_box_object’ filter.
- Refactored to follow coding standards better.
- Documented all the functions, fields, and filters.
- Switched the Navception class to a singleton to avoid registering hooks multiple times.
- Initial Release.