wpseek.com
A WordPress-centric search engine for devs and theme authors
wp_create_categories › WordPress Function
Since2.0.0
Deprecatedn/a
› wp_create_categories ( $categories, $post_id = '' )
Parameters: (2) |
|
Returns: |
|
Defined at: |
|
Codex: |
Creates categories for the given post.
Related Functions: wp_create_category, wp_list_categories, wp_create_term, wp_set_post_categories, get_categories
Source
function wp_create_categories( $categories, $post_id = '' ) { $cat_ids = array(); foreach ( $categories as $category ) { $id = category_exists( $category ); if ( $id ) { $cat_ids[] = $id; } else { $id = wp_create_category( $category ); if ( $id ) { $cat_ids[] = $id; } } } if ( $post_id ) { wp_set_post_categories( $post_id, $cat_ids ); } return $cat_ids; }