Created
December 17, 2020 10:04
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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