Skip to content

Instantly share code, notes, and snippets.

@TimBHowe
Created March 22, 2022 21:14
Show Gist options
  • Save TimBHowe/2e10908988c471541ec75b6c347268f3 to your computer and use it in GitHub Desktop.
Save TimBHowe/2e10908988c471541ec75b6c347268f3 to your computer and use it in GitHub Desktop.
A series of queries to allow you to export the nav_menu_item post type and related data.
SELECT * FROM `wp_posts` WHERE post_type = 'nav_menu_item';
SELECT * FROM `wp_postmeta` WHERE post_id IN (SELECT ID FROM `wp_posts` WHERE post_type = 'nav_menu_item');
SELECT * FROM `wp_term_relationships` WHERE object_id IN(SELECT ID FROM `wp_posts` WHERE post_type = 'nav_menu_item');
SELECT * FROM `wp_term_taxonomy` WHERE term_taxonomy_id IN ( SELECT term_taxonomy_id FROM `wp_term_relationships` WHERE object_id IN(SELECT ID FROM `wp_posts` WHERE post_type = 'nav_menu_item'));
SELECT * FROM `wp_terms` WHERE term_id IN (SELECT term_id FROM `wp_term_taxonomy` WHERE term_taxonomy_id IN ( SELECT term_taxonomy_id FROM `wp_term_relationships` WHERE object_id IN(SELECT ID FROM `wp_posts` WHERE post_type = 'nav_menu_item')));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment