wp_set_post_cats

Sets the categories that the post id belongs to.

Description

(bool|mixed) wp_set_post_cats( (string) $blogid = '1', (int) $post_ID = 0, (array) $post_categories = array() ); 

Returns (bool|mixed)

Parameters (3)

0. $blogid — Optional. (string) => '1'
The blogid.
1. $post_id (int)
The post id.
2. $post_categories — Optional. (array) => array()
The post categories.

Usage

  1. if ( !function_exists( 'wp_set_post_cats' ) ) { 
  2. require_once ABSPATH . WPINC . '/deprecated.php'; 
  3.  
  4. // The blogid. 
  5. $blogid = '1'; 
  6.  
  7. // The post id. 
  8. $post_id = -1; 
  9.  
  10. // The post categories. 
  11. $post_categories = array(); 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = wp_set_post_cats($blogid, $post_id, $post_categories); 
  15.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/deprecated.php  
  1. function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array()) { 
  2. _deprecated_function( __FUNCTION__, '2.1.0', 'wp_set_post_categories()' ); 
  3. return wp_set_post_categories($post_ID, $post_categories);