Languages: English • 日本語 (Add your language)
Set categories for a post.
<?php wp_set_post_categories( $post_ID, $post_categories, $append ) ?>
If no categories are passed with a post ID that has a post type of post, the default category will be used.
Be careful, as wp_set_post_categories will overwrite any existing categories already assigned to the post unless $append is set to true.
If an ID is passed with the categories array that is not associated with a valid category, it will be stripped before the object terms are updated and from the return array.
wp_set_object_terms() performs the same function with more granular control for built in categories and can also be used to set any custom taxonomies.
Since: 2.1.0
wp_set_post_categories() is located in wp-includes/post.php
.