The is_taxonomy_viewable() WordPress PHP function determines whether a taxonomy is considered “viewable”.
Usage
is_taxonomy_viewable( $taxonomy );
Example:
Input:
is_taxonomy_viewable( 'category' );
Output:
true
Parameters
$taxonomy (string|WP_Taxonomy)
– Required. Taxonomy name or object.
More information
See WordPress Developer Resources: is_taxonomy_viewable()
Examples
Check if a custom taxonomy is viewable
Determine if the custom taxonomy ‘book_genre’ is viewable.
$is_viewable = is_taxonomy_viewable( 'book_genre' ); echo $is_viewable ? 'Viewable' : 'Not viewable';
Check if a built-in taxonomy is viewable
Determine if the built-in taxonomy ‘post_tag’ is viewable.
$is_viewable = is_taxonomy_viewable( 'post_tag' ); echo $is_viewable ? 'Viewable' : 'Not viewable';
Get taxonomy object and check if it’s viewable
Get the taxonomy object for ‘category’ and determine if it’s viewable.
$taxonomy_obj = get_taxonomy( 'category' ); $is_viewable = is_taxonomy_viewable( $taxonomy_obj ); echo $is_viewable ? 'Viewable' : 'Not viewable';
Check if a non-existent taxonomy is viewable
Determine if a non-existent taxonomy ‘random_taxonomy’ is viewable.
$is_viewable = is_taxonomy_viewable( 'random_taxonomy' ); echo $is_viewable ? 'Viewable' : 'Not viewable';
Loop through taxonomies and check if they’re viewable
Loop through all registered taxonomies and determine if they’re viewable.
$taxonomies = get_taxonomies(); foreach ( $taxonomies as $taxonomy ) { $is_viewable = is_taxonomy_viewable( $taxonomy ); echo "{$taxonomy}: " . ( $is_viewable ? 'Viewable' : 'Not viewable' ) . "\n"; }