Bulk Change Post Type or Taxonomy in WordPress with a SQL Query

Some tasks that look like they need a plugin can be resolved faster with a single SQL query. Bulk-changing the post type of hundreds of posts, or renaming a taxonomy across the entire database, takes seconds via the MySQL command line or phpMyAdmin — no plugin installation required.

Problem: Hundreds of posts need to be moved from one post type to another, or reassigned to a different taxonomy term — doing it one by one through the WordPress admin interface is not feasible.

Solution: Run a targeted UPDATE SQL statement via phpMyAdmin or wp db query: update post_type in wp_posts to change the post type, or update term_taxonomy_id in wp_term_relationships to reassign taxonomy terms. Always back up the database first.

Change post type. Migrate all posts of type post to a custom post type called issue:

UPDATE wp_posts
SET    post_type = 'issue'
WHERE  post_type = 'post';

If you want to migrate only a subset — for example, posts from a specific category — add a subquery:

UPDATE wp_posts p
INNER JOIN wp_term_relationships tr ON p.ID = tr.object_id
INNER JOIN wp_term_taxonomy tt      ON tr.term_taxonomy_id = tt.term_taxonomy_id
INNER JOIN wp_terms t               ON tt.term_id = t.term_id
SET    p.post_type = 'issue'
WHERE  p.post_type = 'post'
  AND  t.slug      = 'my-category-slug';

Change taxonomy name. Rename the taxonomy category to issues_category for all associated terms:

UPDATE wp_term_taxonomy
SET    taxonomy = 'issues_category'
WHERE  taxonomy = 'category';

After running either query, go to Settings → Permalinks and click Save Changes to flush the rewrite rules, then confirm the changes in the WordPress admin.

NOTE: Always back up the database before running UPDATE queries on production. The queries above affect all matching rows at once with no undo. If you have a large dataset, run a SELECT with the same WHERE clause first to confirm the scope before executing the UPDATE.