Skip to content

Instantly share code, notes, and snippets.

@morgyface
Created December 17, 2020 10:04
Show Gist options
  • Save morgyface/448416a3e32176faef800f3dbc93738e to your computer and use it in GitHub Desktop.
Save morgyface/448416a3e32176faef800f3dbc93738e to your computer and use it in GitHub Desktop.
WordPress get the singular name of the taxonomy the term archive belongs to
<?php
function archive_tax_name() {
$archive_tax_name = null;
if( is_archive() && is_category() ) {
$queried_object = get_queried_object();
$queried_object_taxonomy = $queried_object->taxonomy;
$taxonomy = get_taxonomy($queried_object_taxonomy);
$archive_tax_name = $taxonomy->labels->singular_name;
}
return $archive_tax_name;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment