wp_delete_object_term_relationships()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
wp_delete_object_term_relationships( int $object_id, string|array $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.
Параметры
$object_id
int
обязательный
$taxonomies
string|array
обязательный
Исходный код
wp-includes/taxonomy.php:1993
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' ) );
if ( ! is_array( $term_ids ) ) {
// Skip return value in the case of an error or the 'wp_get_object_terms' filter returning an invalid value.
continue;
}
$term_ids = array_map( 'intval', $term_ids );
wp_remove_object_terms( $object_id, $term_ids, $taxonomy );
}
}
История изменений
| Версия | Описание |
|---|---|
| 2.3.0 | Introduced. |

