wp_set_post_categories ( $post_id = 0, $post_categories = array(), $append = false )

  • (int) post_id Optional. The Post ID. Does not default to the ID of the global $post. Default 0.
  • (int[]|int) post_categories Optional. List of category IDs, or the ID of a single category. Default empty array.
  • (bool) append If true, don't delete existing categories, just add on. If false, replace the categories with the new categories.
  • (array|false|WP_Error) Array of term taxonomy IDs of affected categories. WP_Error or false on failure.
Defined at:


Sets categories for a post.If no categories are provided, the default category is used.

Related Functions

wp_get_post_categories, wp_set_post_cats, wp_set_post_terms, wp_list_categories, wp_set_post_tags

Top Google Results

User discussions

wpseek mobile