Where are Custom Menus saved in the Database for Wordpress 3.0?

Viewed 77014

I've been searching and searching my sql database in phpmyadmin but I can't seem to find where custom menus are stored in the database. Anyone know where it's stored? I have a large menu basically that takes forever to create. I'm in development now and rather than recreating it in production I want to try and copy the sql over to see if it works. Thanks!

9 Answers

The actual menu titles, IDs, and names are stored in the wp_terms table.

Here are the SQL scripts I used:

Get the menus from the wp_term table:

SELECT * FROM wp_terms AS t LEFT JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id WHERE tt.taxonomy = 'nav_menu'

Use the term_id to get get all of the menu titles / links from all the other connected tables. In my opinion this is a terrible relational database. Just replace the tt.term_id with yours from the query above, below is 11.

SELECT p.post_title, p.post_name, p.menu_order, pm.meta_value FROM wp_posts AS p LEFT JOIN wp_term_relationships AS tr ON tr.object_id = p.ID LEFT JOIN wp_term_taxonomy AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id INNER JOIN wp_postmeta AS pm ON p.Id = pm.post_id WHERE p.post_type = 'nav_menu_item' AND tt.term_id = 11 AND pm.meta_key = '_menu_item_url'
Related