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:

  • 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

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

        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;

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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