Skip to content
Prem Tiwari
  • WP Tutorials
  • Plugins
  • About Me
  • Featured On
  • Let’s Talk
Prem Tiwari
Home / WordPress Tutorials / How to move WordPress posts from one category to another 

How to move WordPress posts from one category to another 

ByPrem Tiwari Last updated onApril 12, 2022

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_)"
);
?>

Found it helpful? Share it with your friends on social media!

  • Facebook
  • Post on X
  • LinkedIn
Prem Tiwari

Prem Tiwari is a passionate advocate of open source technology, with over 10+ years of experience in the WordPress domain. He has great experience when it comes to scaled WordPress projects which caters the need for big enterprise clients on WordPress and WordPress VIP-GO platform.

Facebook Twitter Instagram YouTube Linkedin

Post navigation

Previous Previous
Remove Comment URL
NextContinue
Remove SKU From Product detail page with Woocommerce Remove SKU

Collections

  • Crawling and indexing
  • Meetup
  • PHP
  • Plugins
  • SEO
  • Tech Talks
  • WooCommerce Tutorials
  • WordCamp
  • WordPress Tutorials
  • Privacy
  • Cookies
  • Disable Update Notifications
Facebook Twitter Instagram YouTube Linkedin WordPress
Scroll to top
  • WP Tutorials
  • Plugins
  • About Me
  • Featured On
  • Let’s Talk