Support » Fixing WordPress » 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.
Viewing 4 replies - 1 through 4 (of 4 total)
  • 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.
    Thread Starter tdchen

    (@tdchen)

    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.
    chen

    Good 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

    • This reply was modified 4 years, 10 months ago by Kyle Pott.
    • This reply was modified 4 years, 10 months ago by Kyle Pott.
    Thread Starter tdchen

    (@tdchen)

    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

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Where are custom menus stored?’ is closed to new replies.