Get all taxonomies and terms in WordPress
On this page
$args = array(
'public' => true, // only load publicly visible taxonomies
'publicly_queryable' => true, // another check for public taxonomies
'_builtin' => false, // excludes WordPress's built-in taxonomies (like category and post_tag)
);
$taxonomies = get_taxonomies($args, 'objects');
$taxonomy_terms = array();
foreach ($taxonomies as $taxonomy) {
$terms = get_terms(array(
'taxonomy' => $taxonomy->name,
'hide_empty' => false,
));
if (!empty($terms) && !is_wp_error($terms)) {
$taxonomy_terms[$taxonomy->name] = wp_list_pluck($terms, 'name');
} else {
$taxonomy_terms[$taxonomy->name] = array();
}
}
return $taxonomy_terms;