I assign automatically a category to a post when published. But how can i modify this category in admin?
function add_bookcategory_automatically($post_ID) {
global $wpdb;
if(!wp_is_post_revision($post_ID)) {
$bookcat = array (4 );
wp_set_object_terms( $post_ID, $bookcat, 'category');
}
}
add_action('publish_post', 'add_bookcategory_automatically');
For example, now the new post has category with id 4, but i can't change or add category in admin. Every time i save the post, category back to 4 id. How can i modify function?