WordPress.org

Ready to get started?Download WordPress

Codex

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

Function Reference/taxonomy exists

Description

This Conditional Tag checks if the taxonomy name exists by passing a taxonomy name as an argument to it. This is a boolean function uses a global $wp_taxonomies variable for checking if taxonomy name existence, meaning it returns either TRUE if the taxonomy name exist or FALSE if it doesn't exist.

Usage

<?php taxonomy_exists($taxonomy); ?>

Parameters

$taxonomy
(string) (required) The name of the taxonomy
Default: None

Return Values

(boolean) 
True on success, false on failure.

Examples

$taxonomy_exist = taxonomy_exists('category');
//returns true

$taxonomy_exist = taxonomy_exists('post_tag');
//returns true

$taxonomy_exist = taxonomy_exists('link_category');
//returns true

$taxonomy_exist = taxonomy_exists('my_taxonomy');
//returns false if global $wp_taxonomies['my_taxonomy'] is not set

Notes

Change Log

Since: 3.0

Source File

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

Related

post_type_exists()

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