jasonaburton
jasonaburton

Reputation: 3103

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.

Any help is appreciated. Thanks!

Upvotes: 1

Views: 2211

Answers (1)

jasonaburton
jasonaburton

Reputation: 3103

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.

Upvotes: 2

Related Questions