wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.
wp_create_categories › WordPress Function
Od2.0.0
Przestarzałyn/a
› wp_create_categories ( $categories, $post_id = '' )
Parametry: (2) |
|
Powrót: |
|
Zdefiniowane na: |
|
Codex: |
Creates categories for the given post.
Powiązane Funkcje: wp_create_category, wp_list_categories, wp_create_term, wp_get_post_categories, wp_set_post_categories
Źródło
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; }