Codex tools: Log in
Contents |
Get a list of registered taxonomy objects.
<?php get_taxonomies( $args, $output, $operator ) ?>
The call to get_taxonomies returns the registered taxonomies.
<?php $taxonomies=get_taxonomies(); ?>
<?php
$taxonomies=get_taxonomies('','names');
foreach ($taxonomies as $taxonomy ) {
echo '<p>'. $taxonomy. '</p>';
}
?>
This return all custom (not builtin) taxonomies.
<?php
$args=array(
'public' => true,
'_builtin' => false
);
$output = 'names'; // or objects
$operator = 'and'; // 'and' or 'or'
$taxonomies=get_taxonomies($args,$output,$operator);
if ($taxonomies) {
foreach ($taxonomies as $taxonomy ) {
echo '<p>'. $taxonomy. '</p>';
}
}
?>
This example uses the 'object' output to retrieve and display the taxonomy called 'genre':
<?php
$args=array(
'name' => 'genre'
);
$output = 'objects'; // or objects
$taxonomies=get_taxonomies($args,$output);
if ($taxonomies) {
foreach ($taxonomies as $taxonomy ) {
echo '<p>' . $taxonomy->name . '</p>';
}
}
?>
get_taxonomies() is located in wp-includes/taxonomy.php.