Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to write a routine that will pull items from the wp_options table in order to transport them to another site.

The problem I have is that if the source site has custom menus, I'd like to bring those along as well. What table records are referenced for custom menus?

I see at least these three in wp_options:

widget_nav_menu
theme_mods_myTheme
myTheme_menus_created
share|improve this question
    
As far as i know the custom menu items are CPT. –  Sisir Jul 7 '12 at 8:34
1  
WordPress menus are exported by the built-in WordPress exporter tool under Tools -> Export. Why don't you use this functionality? –  Mateusz Hajdziony Nov 18 '12 at 6:01

1 Answer 1

Menus aren't stored in options. They are linked quite complicatedly so through various other tables.

$wpdb->get_results(sprintf("
        select tr.object_id from wp_terms t 
        left join wp_term_taxonomy tt on t.term_id = tt.term_id
        left join wp_term_relationships tr on tt.term_taxonomy_id = tr.term_taxonomy_id
        left join wp_posts p on p.ID=tr.object_id
        left join wp_postmeta m on m.post_id=tr.object_id
        where t.slug ='%s' and tt.taxonomy='nav_menu' group by(ID)
        order by p.menu_order asc LIMIT 200;
        ",$menu));

where $menu is the slug of the menu such as main, footer or whatever you may have called it.

The query outlines the relationships that you have to account for.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.