Title: Mikael Olsson's Replies | WordPress.org

---

# Mikael Olsson

  [  ](https://wordpress.org/support/users/emmio/)

 *   [Profile](https://wordpress.org/support/users/emmio/)
 *   [Topics Started](https://wordpress.org/support/users/emmio/topics/)
 *   [Replies Created](https://wordpress.org/support/users/emmio/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/emmio/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/emmio/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/emmio/engagements/)
 *   [Favorites](https://wordpress.org/support/users/emmio/favorites/)

 Search replies:

## Forum Replies Created

Viewing 1 replies (of 1 total)

 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [WP 3.0 Where are Menu Items and Relationships Stored?](https://wordpress.org/support/topic/wp-30-where-are-menu-items-and-relationships-stored/)
 *  [Mikael Olsson](https://wordpress.org/support/users/emmio/)
 * (@emmio)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/wp-30-where-are-menu-items-and-relationships-stored/#post-1569249)
 * I’ve been looking into this myself and I think I have a good grasp on the menues
   now. This post is fairly old, but someone might find this useful… It’s not a 
   guide on how to build menues etc, I’m merely trying to share my findings of the
   construction.
 * First off, to find the menues you have to find the taxonomy ids.
 * SELECT *
    FROM wp_term_taxonomy tt INNER JOIN wp_terms t ON tt.term_id = t.term_id
   WHERE tt.taxonomy = ‘nav_menu’;
 * There you should find the menu names and their ids. In this example, my menu 
   is called ‘Main menu’ and has term_id 8.
 * Secondly, to find all related menu items we turn to wp_term_relationships:
 * SELECT *
    FROM wp_term_relationships tr WHERE tr.term_taxonomy_id = 8; # 8 would
   be the menu in this example.
 * The object_ids returned represent the posts that are used for menu items. Ie,
   wp_term_relationships.object_id => wp_posts.ID.
 * To get the structure, look in wp_post_meta. You’ll find the data parentid for
   each item by this query:
 * SELECT *
    FROM wp_postmeta pm WHERE post_id = 77; # 77 being the first post returned
   from wp_term_relationships. In this example, this is the result:
 * meta_id, post_id, meta_key, wp_postmeta, meta_value
    ‘499’, ’77’, ‘_menu_item_type’,‘
   custom’ ‘500’, ’77’, ‘_menu_item_menu_item_parent’, ‘0’ ‘501’, ’77’, ‘_menu_item_object_id’,’
   77’ ‘502’, ’77’, ‘_menu_item_object’, ‘custom’ ‘503’, ’77’, ‘_menu_item_target’,”‘
   504’, ’77’, ‘_menu_item_classes’, ‘a:1:{i:0;s:0:””;}’ ‘505’, ’77’, ‘_menu_item_xfn’,”‘
   506’, ’77’, ‘_menu_item_url’, ‘[http://localhost/mysite/&#8217](http://localhost/mysite/&#8217);
 * Use meta_key = ‘_menu_item_menu_item_parent’ (and wp_posts.menu_order) to get
   the menu structure.
 * Hope this helps someone.

Viewing 1 replies (of 1 total)