How to move WordPress posts from one category to another 

If you want to move all your WordPress posts from one category to another category then this MySQL query can be done without using any WordPress plugins. you can do it with the below simple MySQL query.

update your_wp_prefix_term_relationships set
term_taxonomy_id=
(select term_taxonomy_id from your_wp_prefix_term_taxonomy where term_id=_ID_NEW_)
where
term_taxonomy_id=
(select term_taxonomy_id from your_wp_prefix_term_taxonomy where term_id=_ID_OLD_)

You can also achieve the same by using WordPress code inside your theme/plugin files.

<?php
// Move WordPress posts from one category to another.
$wpdb->query("update $wpdb->term_relationships set
term_taxonomy_id=
(select term_taxonomy_id from $wpdb->term_taxonomy where term_id=_ID_NEW_)
where
term_taxonomy_id=
(select term_taxonomy_id from $wpdb->term_taxonomy where term_id=_ID_OLD_)"
);
?>

Leave a Comment