Need help? Book our fixed price WordPress Support service.

Update WordPress Post Type using SQL

If you need to switch post types in WordPress, you can do this quickly using the free plugin “Post Type Switcher” available on the WordPress respository (https://en-gb.wordpress.org/plugins/p…).

If you need to do this programmatically, it’s also simple to do this using some basic SQL. In this video I explain how.

Don’t forget to backup first!

SQL Used (adapt table names and post types for your own database and requirements):

To display your post types:
SELECT distinct post_type
FROM wp_posts

To update using ID:
UPDATE wp_posts
SET post_type = 'knowledgebase'
WHERE id in (1783,1784,1785,1786, 1787,1788)

To update everything
UPDATE wp_posts
SET post_type = 'knowledgebase'
WHERE post_type = 'post'

Was this article helpful?

No 0

About the Author

@recreincome - A WordPress consultant and blogger specialising in using WordPress to create passive and secondary income streams

LEAVE COMMENT