wp_delete_object_term_relationships( int $object_id, string|array $taxonomies )

Will unlink the object from the taxonomy or taxonomies.


Description Description

Will remove all relationships between the object and any terms in a particular taxonomy or taxonomies. Does not remove the term or taxonomy itself.


Top ↑

Parameters Parameters

$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.


Top ↑

Source Source

File: wp-includes/taxonomy.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 );
	}
}


Top ↑

Changelog Changelog

Changelog
Version Description
2.3.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.