How to Change Post Category Programatically – WordPress

This is just a little snippet that allow us to update post category programmatically, sure it’s a bit easy to update post category via PHPMyAdmin, MySQL Console and the easiest one is in the WordPress Dashboard but in some cases like by creating plugin or custom code we’d like to do it programmatically, so here you go, hope you’ll find this useful.


If you’ve added terms as ID, try making it as array.

You can find out more here

That’s it, Happy coding ^_^

by Ryan Sutana