taxonomy_exists( string $taxonomy ): bool

Determines whether the taxonomy name exists.

Description

Formerly is_taxonomy() , introduced in 2.3.0.

For more information on this and similar theme functions, check out the Conditional Tags article in the Theme Developer Handbook.

Parameters

$taxonomystringrequired
Name of taxonomy object.

Return

bool Whether the taxonomy exists.

Source

function taxonomy_exists( $taxonomy ) {
	global $wp_taxonomies;

	return is_string( $taxonomy ) && isset( $wp_taxonomies[ $taxonomy ] );
}

Changelog

VersionDescription
3.0.0Introduced.

User Contributed Notes

  1. Skip to note 2 content

    Basic Example

    $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

You must log in before being able to contribute a note or feedback.