I started developing a site with over a dozen custom post types. I'd like to rename a few of them, not just the display value, but the actual custom post type name. I'm worried however that by just running a SQL update query that I'll miss some places where I need to change things or overwrite part of serialized data. I have already inputed over 3,000 items, so I can't just restart with a clean database.

What would be the best way to rename a custom post type? How about renaming a taxonomy?

  • A follow-up question in the same vein is regarding custom .htaccess rewrite rules. Will there be a lot of leftover rules clogging up my database? I haven't launched the site yet, so I don't need any of the old links to be redirected. Sep 1, 2010 at 5:43

3 Answers 3


SQL query for renaming the posts:

UPDATE  `wp_posts` SET  `post_type` =  '<new post type name>' WHERE  `post_type` = '<old post type name>';

SQL query for renaming taxonomy:

UPDATE  `wp_term_taxonomy` SET  `taxonomy` =  '<new taxonomy name>' WHERE  `taxonomy` = '<old taxonomy name>';

That should take care of all of the database areas. Just remember to match the new names in the code where the post types or taxonomies are registered. As far as I know, this is not handled in any plugins yet.

  • 10
    Excellent answer, exactly what I needed. Here's a tip in case others hit the same problem as I did: After I ran the query and updated my code, things were basically working but when I tried going to the page for an individual content item I got a 404 error. I think some permalink cache needed to be reset; I went to Tools > Permalinks and clicked Save, then the detailed pages started working. Mar 11, 2011 at 20:06
  • When I did this, I updated the guid field as well. This might help make it unnecessary to regenerate permalinks as @AndyGiesler mentioned. Just include the following in your UPDATE statement: guid=REPLACE(guid, '<old post type name>', '<new post type name>')
    – rinogo
    Mar 1, 2013 at 20:44
  • Just to add a little more info to rinogo's comment, this is a little safer way to update the guid: UPDATE wp_posts SET guid = REPLACE (guid, 'post_type=<old post type name>', 'post_type=<new post type name>');
    – David
    Feb 13, 2014 at 5:49
  • just to note you will need to watch your table names when running on multisite
    – rmorse
    May 21, 2014 at 20:02

Hi @Derek Perkins:

In general @John P Bloch's answer is spot on but with a caveat. Plugins and even custom themes can and may store post type information and thus in order to be sure that you won't corrupt your data you need to ensure your plugins and themes don't store post types or if they do that you update their data as well.

Can you tell us what plugins you are using?

  • That's a good point. I'm building my theme custom, so I'll definitely have to go through and change my code around. I don't have any plugins that are storing custom post type info however. Sep 1, 2010 at 5:23
  • This is a good point. I was using Advanced Custom Fields, and for each field group attached to that post you have to manually reset it to the new CPT name. After that it works fine though.
    – Chris Rae
    Dec 11, 2015 at 20:51

If you don't want to have to perform the SQL queries yourself manual there are a couple of plugins you can use:

I've successfully used Convert Post Types to mass change posts.

For converting invididual posts then Post Type Switcher is a better option.

  • Thanks for posting those links. I'm fine running the SQL queries myself, but those will definitely come in handy for others that come across this posting. Sep 1, 2010 at 5:24
  • this seems to convert post types, not rename them
    – vladkras
    Aug 15, 2015 at 12:49

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.