wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
wp_create_categories › WordPress Function
Seit2.0.0
Veraltetn/v
› wp_create_categories ( $categories, $post_id = 0 )
| Parameter: (2) |
|
| Gibt zurück: |
|
| Definiert in: |
|
| Codex: |
Creates categories for the given post.
Ähnliche Funktionen: wp_create_category, wp_list_categories, get_categories, wp_create_term, wp_get_post_categories
Quellcode
function wp_create_categories( $categories, $post_id = 0 ) {
$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;
}