Bulk move WordPress posts from one category to another one

This can be done with plugins, there might be such plugins. But you can aldo do it with one simple sql 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_)


This mysql code is for mysql editors of course.
Running this code via php:

<?php
$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 Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.