WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/wp delete object term relationships

Description

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 the taxonomy itself.

Usage

<?php wp_delete_object_term_relationships$object_id$taxonomies ); ?>

Parameters

$object_id
(int) (required) The term Object ID that refers to the term.
Default: None
$taxonomies
(string|array) (required) List of Taxonomy Names or single Taxonomy name.
Default: None

Return Values

This function does not return a value.

Example

Delete all tag relationships for a post:

<?php

$post_id = 55;

wp_delete_object_term_relationships( $post_id, 'post_tag' );

// Post 55 now has no tags.

?>

Delete multiple taxonomies' relationships for a post:

<?php

$post_id = 55;
$taxonomies = array( 'category', 'post_tag', 'custom_taxonomy' );

wp_delete_object_term_relationships( $post_id, $taxonomies );

?>

Notes

Change Log

Since: 2.3.0

Source File

wp_delete_object_term_relationships() is located in wp-includes/taxonomy.php.

Related

wp_remove_object_terms()

See also index of Function Reference and index of Template Tags.