WordPress.org

Ready to get started?Download WordPress

Codex

Function Reference/is object in term

Contents

Description

Determines if the given object is associated with any of the given terms.

The given terms are checked against the object’s terms’ term_ids, names and slugs. Terms given as integers will only be checked against the object’s terms’ term_ids. If no terms are given, determines if object is associated with any terms in the given taxonomy.

Usage

<?php is_object_in_term$object_id$taxonomy$terms null ?>

Parameters

$object_id
(integer) (required) ID of the object to check. (post ID, link ID, etc.)
Default: None
$taxonomy
(string) (required) A single taxonomy name.
Default: None
$terms
(mixed) (optional) The term ID, name or slug or an array of such.
Default: NULL

Examples

<?php
if ( is_object_in_term( $post->ID, 'custom_taxonomy_name', 'term_name' ) ) :
	echo 'YES';
else :
	echo 'NO';
endif;
?>

Notes

Changelog

Source File

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

Related

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