2

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
2
  • As far as i know the custom menu items are CPT.
    – Sisir
    Jul 7, 2012 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? Nov 18, 2012 at 6:01

1 Answer 1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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