Support » Fixing WordPress » Where are custom menus stored?
Where are custom menus stored?
-
We can create a custom menu in the admin area.
I think it is stored somewhere.
But I can find it in WP database.
What is the trick?
Thanks- This topic was modified 4 years, 10 months ago by tdchen.
- This topic was modified 4 years, 10 months ago by Jan Dembowski.
-
Hi there! What you may be looking for is the menu_order and post_type fields within the wp_posts table.
https://codex.wordpress.org/Database_Description#Table:_wp_posts
Kyle
- This reply was modified 4 years, 10 months ago by Kyle Pott.
Hi Kyle.
If things like this, how WP print the menu on the page?
It seems too complicated to imaging how the menu is assembled.
chenGood morning, Chen.
Here’s a link that really shows the detailed mechanics of how the menu is called from the backend and displayed on the frontend. This resides within the /wp-includes/nav-menu.php file.
https://developer.wordpress.org/reference/functions/wp_get_nav_menu_items/
Toward the bottom of that page also check out this function wp-admin/includes/nav-menu.php: wp_get_nav_menu_to_edit() which returns the menu formatted to edit.
function wp_get_nav_menu_to_edit( $menu_id = 0 ) { $menu = wp_get_nav_menu_object( $menu_id ); // If the menu exists, get its items. if ( is_nav_menu( $menu ) ) { $menu_items = wp_get_nav_menu_items( $menu->term_id, array( 'post_status' => 'any' ) ); $result = '<div id="menu-instructions" class="post-body-plain'; $result .= ( ! empty( $menu_items ) ) ? ' menu-instructions-inactive">' : '">'; $result .= '<p>' . __( 'Add menu items from the column on the left.' ) . '</p>'; $result .= '</div>';
Kyle
thank you Kyle
sorry for my late of replying.
you give me the key.
so, if we want to see where the menu is stored, we should look into wp_get_nav_menu_object(). and go deeper.
chen
- The topic ‘Where are custom menus stored?’ is closed to new replies.