Menu by itself is a taxonomy in WordPress. It means that you can find all menus in wp_terms
table, by running following query:
1 2 3 4 |
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'; |
Menu item is custom post type in WordPress. They are stored in wp_posts
table. You can find all of them by using this query:
1 2 3 |
SELECT * FROM wp_posts WHERE post_type = 'nav_menu_item'; |
Relations between menus and menu items are stored in wp_term_relationships
table. To find all items of specific menu you can use this query:
1 2 3 4 5 6 |
SELECT p.* 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 WHERE p.post_type = 'nav_menu_item' AND tt.term_id = /*your menu ID*/; |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.