categories not updating with wp_update_post

When I run wp_update_post, it doesn’t update the categories:

$update = array('ID' => 1623, 'post_category' => array(219), 'post_content' => "Test");

wp_update_post($update);

I should mention that it does update the post with the post_content, so the post is being updated, but I have no idea why it’s not updating the categories.

Read More

Any help is appreciated. Thanks!

Related posts

Leave a Reply

1 comment

  1. If it’s a custom taxonomy use:

    wp_set_post_terms() 
    

    to set the category for a post. Then use:

    wp_update_post();
    

    to update the post that the category was set to.