Last active
April 9, 2019 15:29
-
-
Save calebergh/435cf1a2fe8a11197739f1030d8beb15 to your computer and use it in GitHub Desktop.
SQL queries to migrate all terms / posts from one taxonomy into another (WordPress)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This example is using a TARGET taxonomy of post_tag (WP native tags) and SOURCE of channel (custom taxonomy) | |
-- First, if desired, purge existing post relationships from target taxonomy | |
DELETE r FROM wp_term_relationships AS r | |
INNER JOIN wp_term_taxonomy AS t | |
ON r.term_taxonomy_id = t.term_taxonomy_id | |
WHERE taxonomy = 'post_tag' | |
-- Then, if desired, purge existing terms from target taxonomy | |
DELETE FROM `wp_term_taxonomy` WHERE taxonomy = 'post_tag' | |
-- Finally, migrate all existing post relationships / terms from source to target | |
UPDATE wp_term_taxonomy SET taxonomy = 'post_tag' WHERE taxonomy = 'channel' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment