wp_delete_object_term_relationships
函数
wp_delete_object_term_relationships ( $object_id, $taxonomies )
- 参数
-
-
(int)
$object_id
The term object ID that refers to the term.- Required: 是
-
(string|array)
$taxonomies
List of taxonomy names or single taxonomy name.- Required: 是
-
(int)
- 定义位置
-
-
wp-includes/taxonomy.php
, line 1911
-
wp-includes/taxonomy.php
- 引入
- 2.3.0
- 弃用
- –
Unlinks the object from the taxonomy or taxonomies.
Will remove all relationships between the object and any terms in
a particular taxonomy or taxonomies. Does not remove the term or
taxonomy itself.
function wp_delete_object_term_relationships( $object_id, $taxonomies ) { $object_id = (int) $object_id; if ( ! is_array( $taxonomies ) ) { $taxonomies = array( $taxonomies ); } foreach ( (array) $taxonomies as $taxonomy ) { $term_ids = wp_get_object_terms( $object_id, $taxonomy, array( 'fields' => 'ids' ) ); $term_ids = array_map( 'intval', $term_ids ); wp_remove_object_terms( $object_id, $term_ids, $taxonomy ); } }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。