I want to export all Wordpress categories (no posts, just categories) from one blog to another. How can I do that ?

  • Have you tried accessing Manage>Export from the blog's Admin panel.
    – Omtara
    Nov 25 '11 at 17:40
  • There is no Manage menu, there is only Tools/Export menu but it doens't allow me to export categories only
    – chubbyk
    Nov 25 '11 at 17:44
  • Sorry for that, I read that from a blog online. Could you do that from the database level?
    – Omtara
    Nov 25 '11 at 17:59
  • If you need a simple effort, try Export Categories plugin. wordpress.org/plugins/export-categories
    – user105070
    Oct 17 '16 at 6:50

This answer is essentially the same as Ünsal's, but I'd like to elaborate a bit because despite being right his answer didn't help me (I was just trying to remember what I'd done in the past, I should have read his more carefully and I would have figured it out, but I think for others a full description would be useful).

To export the full category hierarchy you need to export "All Content"

Any other option won't give you the full data (e.g. exporting a post with all categories tagged mostly works, but you lose all parentage/hierarchy data about taxonomies that are hierarchical).

When you export "All Content" the resulting file has a section with data about your terms. If you look through the file it should be easy enough to find, after authors and before "items" (i.e. posts).

You can just import this and delete content if that's an option*

Importing the full file will replicate the taxonomy hierarchy perfectly, but also obviously import all the pages and posts too. If there aren't too many than consider just deleting them by hand. It won't take that long if you do it bulk and there are less than hundreds (remember you can use Screen Options on the Edit Posts screen to show more than the default and thus bulk edit more at a time).

If you have too much content to remove it all then you need to edit the WXR file by hand to remove everything but the terms you want to keep.

Editing the WXR file to remove content

This can be a bit tricky but really if you look at the contents of the file it's not that hard to figure out what each element does. XML is like HTML with tags, so the main thing to be careful of is that you don't delete a closing tag while leaving the opening tag etc.

You'll find that there are 1-3 types of term definitions in the WXR, one type for Categories, one for "tags" and one for "terms". "Custom taxonomies" use terms while old-fashioned categories and tags have their own special format.


<wp:category><wp:term_id>8880</wp:term_id><wp:category_nicename>runner-up-proposals</wp:category_nicename><wp:category_parent>second-round-proposals</wp:category_parent><wp:cat_name><![CDATA[Runner-up Proposals]]></wp:cat_name></wp:category>


<wp:tag><wp:term_id>122</wp:term_id><wp:tag_slug>ave-maria</wp:tag_slug><wp:tag_name><![CDATA[Ave Maria]]></wp:tag_name></wp:tag>


<wp:term><wp:term_id>8579</wp:term_id><wp:term_taxonomy>gv_tools</wp:term_taxonomy><wp:term_slug>digital-video</wp:term_slug><wp:term_parent></wp:term_parent><wp:term_name><![CDATA[Digital Video]]></wp:term_name></wp:term>

So what you want to do is remove all content other than these category/tag/term tags from the WXR file. Namely wp:author tags that come before and the many item tags that come after. Most importantly: Don't remove the closing /channel and /rss tags at the bottom! Without them the XML won't validate.

OBVIOUSLY you will test the results of importing your edited file before using it on a live website. Try importing it into a fresh install locally and see if it fails completely, then check the categories listing screen in wp-admin and make sure everything is exactly as you expected.

Good luck!

  • 1
    Note that this will not add a hierarchy to categories that have already been created. It will only assign parent categories to subcategories that don't already exist.
    – Zade
    Oct 10 '19 at 6:09

I solved this problem with 2 queries.

This is not the best way I suppose, but for sure not the safest. Furthermore it assumes that you are working on the same database (if this is not the case you can easily export the query and then import into another db).

I've used it on an empty wordpress installation:

1 - Import the category's terms:

INSERT INTO newwp_terms
  FROM oldwp_terms te
  JOIN oldwp_term_taxonomy ta
    ON te.term_id = ta.term_id
 WHERE ta.taxonomy = 'category'

2 - Import categories relationships and descriptions

INSERT INTO newwp_term_taxonomy
SELECT term_taxonomy_id,term_id,taxonomy,description,parent,0
  FROM oldwp_term_taxonomy ta
  WHERE ta.term_taxonomy_id IN
           SELECT ta2.term_taxonomy_id
             FROM oldwp_terms te
             JOIN oldwp_term_taxonomy ta2
               ON te.term_id = ta2.term_id
            WHERE ta.taxonomy = 'category'

[A]nyway newwp_ refers to table into which you want to import while oldwp_ refers to source table


You cant export only categories (or taxonomies generally). Just export all content with Tools/Export and you can delete content except categories from xml.


What is your end goal here? Just to get a list of categories from one blog to another? Or, are you trying to move all of the content wihtin a category or categories to another WordPress install?

It kinda ugly, but you could export all content, then just delete the content within the categories or delete the categories that you don't want. It would probably be one of the quicker ways to your goal.


If you have access to the database tables you can do a mysql dump export of the wp_term_relationships, wp_term_taxonomy, wp_terms tables and import those into the new wordpress installation. I just did this between two WP installs with over 300 categories and it worked fine.

  • thanks, this worked well on my end.
    – Nikhil VJ
    Sep 15 '19 at 18:03

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.