wp_update_category
函数
wp_update_category ( $catarr )
- 参数
-
-
(array)
$catarr
The ‘cat_ID’ value is required. All other keys are optional.- Required: 是
-
(array)
- 返回值
-
- (int|false) The ID number of the new or updated Category on success. Zero or FALSE on failure.
- 定义位置
-
-
wp-admin/includes/taxonomy.php
, line 188
-
wp-admin/includes/taxonomy.php
- 引入
- 2.0.0
- 弃用
- –
Aliases wp_insert_category() with minimal args.
If you want to update only some fields of an existing category, call this
function with only the new values set inside $catarr.
function wp_update_category( $catarr ) { $cat_ID = (int) $catarr['cat_ID']; if ( isset( $catarr['category_parent'] ) && ( $cat_ID == $catarr['category_parent'] ) ) { return false; } // First, get all of the original fields. $category = get_term( $cat_ID, 'category', ARRAY_A ); _make_cat_compat( $category ); // Escape data pulled from DB. $category = wp_slash( $category ); // Merge old and new fields with new fields overwriting old ones. $catarr = array_merge( $category, $catarr ); return wp_insert_category( $catarr ); }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。