wp_delete_object_term_relationships

The timeline below displays how wordpress function wp_delete_object_term_relationships has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * 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.
 *
 * @since 2.3.0
 *
 * @param int          $object_id  The term object ID that refers to the term.
 * @param string|array $taxonomies List of taxonomy names or single taxonomy name.
 */
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);
    }
}

WordPress Version: 5.9

/**
 * 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.
 *
 * @since 2.3.0
 *
 * @param int          $object_id  The term object ID that refers to the term.
 * @param string|array $taxonomies List of taxonomy names or single taxonomy name.
 */
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);
    }
}

WordPress Version: 4.3

/**
 * 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.
 *
 * @since 2.3.0
 *
 * @param int          $object_id  The term Object Id that refers to the term.
 * @param string|array $taxonomies List of Taxonomy Names or single Taxonomy name.
 */
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);
    }
}

WordPress Version: 4.1

/**
 * 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.
 *
 * @since 2.3.0
 *
 * @param int $object_id The term Object Id that refers to the term
 * @param string|array $taxonomies List of Taxonomy Names or single Taxonomy name.
 */
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);
    }
}

WordPress Version: 3.9

/**
 * 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.
 *
 * @since 2.3.0
 * @uses wp_remove_object_terms()
 *
 * @param int $object_id The term Object Id that refers to the term
 * @param string|array $taxonomies List of Taxonomy Names or single Taxonomy name.
 */
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);
    }
}

WordPress Version: 3.7

/**
 * 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.
 *
 * @package WordPress
 * @subpackage Taxonomy
 * @since 2.3.0
 * @uses wp_remove_object_terms()
 *
 * @param int $object_id The term Object Id that refers to the term
 * @param string|array $taxonomies List of Taxonomy Names or single Taxonomy name.
 */
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);
    }
}