WordPress at a glance

wp_delete_object_term_relationships() WP 1.0

Will unlink 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.

Works based on: wp_remove_object_terms()

No Hooks.

Return

Nothing (null).

Usage

wp_delete_object_term_relationships( $object_id, $taxonomies );
$object_id(int) (required)
The term Object Id that refers to the term.
$taxonomies(string/array) (required)
List of Taxonomy Names or single Taxonomy name.

Code of wp_delete_object_term_relationships: wp-includes/taxonomy.php VER 4.9.8

<?php
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 );
	}
}

Related Functions

From tag: Term (taxonomies terms)

More from category: For posts

No comments
    Hello, !     Log In . Register