is_object_in_taxonomy

Determine if the given object type is associated with the given taxonomy.

Description

is_object_in_taxonomy( (string) $object_type, (string) $taxonomy ); 

Parameters (2)

0. $object_type (string)
Object type string.
1. $taxonomy (string)
Single taxonomy name.

Usage

  1. if ( !function_exists( 'is_object_in_taxonomy' ) ) { 
  2. require_once ABSPATH . WPINC . '/taxonomy.php'; 
  3.  
  4. // Object type string. 
  5. $object_type = ''; 
  6.  
  7. // Single taxonomy name. 
  8. $taxonomy = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = is_object_in_taxonomy($object_type, $taxonomy); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/taxonomy.php  
  1. function is_object_in_taxonomy( $object_type, $taxonomy ) { 
  2. $taxonomies = get_object_taxonomies( $object_type ); 
  3. if ( empty( $taxonomies ) ) { 
  4. return false; 
  5. return in_array( $taxonomy, $taxonomies );