Lately one of the project i’m involved in is having this weird issue which unable to save the whole menu items we made (The menu item saving process is suddenly ended after 80-something menu items are saved). Okay, it is idea of mine to use mega dropdown menu but i didn’t expect that it is going to have hundreds of menu item on it LOL Weirdly, it works well on local and development server. Considering this issue i think the problem is not the incapability of WordPress in handling hundreds of menu-item. I (currently) believe that the problem is on the server configuration which we’re still working on it.
However, there is a requirement to add more menu item. Since it is currently unable to save more menu-item through dashboard interface, i decided to figure out how WordPress menu works and insert the menu item directly through the database (i’m using PhpMyAdmin) while we’re working on the server configuration issue. After some couple of times messing with the database, i finally get how it works.
If you’re about to ‘directly insert‘ a menu-item to existing menu location, there are three tables that you’re going to modify:
wp_postmeta. However, if you’re going to see it on its bigger picture,
wp_term_taxonomy is also involved in this.
Let’s say I’m going to add a custom menu item with “
@fikrirasyid” as its label and a link to my twitter profile “http://twitter.com/fikrirasyid” as its URL.
1. Insert new record to
These are some fields you have to pay attention to:
ID: The ID of the item
post_title: Information that will be used as “label” of the menu-item
post_status: make sure it’s “publish”
post_name: Information that will be used as its slug
menu_order: information that is used to determine the order of the menu-item.
post_type: Make sure that it’s “nav_menu_item”
2. Insert new record to
for more understanding toward
term_taxonomy_id field, take a look at
wp_term_taxonomy tables below.
3. Insert 8 new records to
Finally here’s the last recipe. These 8 records on the
wp_postmeta are where the values of menu-item is stored.
Anyway, there is further note you need to know for these
_menu_item_object: there is custom, pages, categories, custom taxonomies, and so on and so forth.
_menu_item_object_id: If the type of menu-item is page, then this
meta_keywill store the value of page
ID(note that it’s page
wp_posts, not the
IDversion of it)
IDof parent menu item
And that’s it. To comprehend it more, it’ll be a good idea to take a look to your existing local WordPress site’s database and understand it in your own situation.