WordPress.org

Ready to get started?Download WordPress

Codex

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

Difference between revisions of "Function Reference/wp remove object terms"

m (Return)
(Add function info from phpdoc)
Line 1: Line 1:
 
==Description==
 
==Description==
  +
Remove term(s) associated with a given object.
   
 
==Parameters==
 
==Parameters==
{{Parameter|$var|TYPE|Description.}}
+
{{Parameter|$object_id|int|The ID of the object from which the terms will be removed.}}
{{Parameter|$var|TYPE|Description.|optional|DEFAULT}}
+
{{Parameter|$terms|mixed|The slug(s) or ID(s) of the term(s) to remove. Accepts array, int or string.}}
  +
{{Parameter|$taxonomy|mixed|The taxonomy name.}}
   
 
== Return ==
 
== Return ==
{{Return||TYPE|Description.}}
+
{{Return||mixed|True on success, false or WP_Error on failure.}}
   
 
== Usage ==
 
== Usage ==
%%% <?php ?> %%%
+
%%% <?php wp_remove_object_terms( $id, $terms, $taxonomy ); ?> %%%
   
 
==Example==
 
==Example==
Description text
+
Remove tag from post.
 
<pre>
 
<pre>
Example code
+
wp_remove_object_terms( $post_id, 'sweet', 'post_tag' );
 
</pre>
 
</pre>
   
Line 22: Line 23:
 
== Source File ==
 
== Source File ==
 
<!-- Need links to current source code files -->
 
<!-- Need links to current source code files -->
<tt>wp_remove_object_terms()</tt> is located in {{Trac|wp-whatever/file.php}}.
+
<tt>wp_remove_object_terms()</tt> is located in {{Trac|wp-includes/taxonomy.php}}.
   
 
==Related==
 
==Related==
Function ref links
+
[[Function_Reference/wp_add_object_terms|wp_add_object_terms()]]
  +
[[Function_Reference/wp_set_object_terms|wp_set_object_terms()]]
   
 
[[Category:Functions]]
 
[[Category:Functions]]
 
{{Copyedit}}
 

Revision as of 16:26, 18 May 2013

Description

Remove term(s) associated with a given object.

Parameters

$object_id
(int) (required) The ID of the object from which the terms will be removed.
Default: None
$terms
(mixed) (required) The slug(s) or ID(s) of the term(s) to remove. Accepts array, int or string.
Default: None
$taxonomy
(mixed) (required) The taxonomy name.
Default: None

Return

(mixed) 
True on success, false or WP_Error on failure.

Usage

 <?php wp_remove_object_terms$id$terms$taxonomy ); ?> 

Example

Remove tag from post.

wp_remove_object_terms( $post_id, 'sweet', 'post_tag' );

Change Log

Source File

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

Related

wp_add_object_terms() wp_set_object_terms()