-
-
Save yumyo/8044cde315ca12100f92ca0d489a9211 to your computer and use it in GitHub Desktop.
WordPress Archive Title conditionals to correct display
This file contains 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_title() { | |
//Conditionals to Title Display in WordPress Archive Templates | |
if( is_archive() ) { | |
$queried_object = get_queried_object(); | |
if( is_tag() ) { | |
$slug = $queried_object ? $queried_object->slug : ' ' ; | |
return ucfirst( $queried_object->name ); | |
} else if( is_tax() ){ | |
$slug = $queried_object ? $queried_object->slug : ' ' ; | |
return ucfirst( $queried_object->name ); | |
} else { | |
$slug = $queried_object ? $queried_object->rewrite['slug'] : ' ' ; | |
return $queried_object->labels->name; | |
} | |
//Fallback if there's no archive matching the conditions | |
return 'Archives'; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment