Created
August 21, 2014 18:07
-
-
Save ChrisCree/7c73b3e48837d7210a1c to your computer and use it in GitHub Desktop.
Add relevant page titles to custom taxonomy archive pages. This code can be dropped in the functions.php file. If used in a taxonomy.php template then omit the is_tax() conditional.
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 | |
// Do not copy opening PHP tag above | |
// Add titles to custom taxonomy archive pages | |
add_action( 'genesis_before_loop', 'wsm_add_taxonomy_title' ); | |
function wsm_add_taxonomy_title() { | |
if( is_tax() ) { | |
global $wp_query; | |
$term = $wp_query->get_queried_object(); | |
$tax = $term->taxonomy; | |
$title = $term->name; | |
echo '<h1 class="entry-title">' . $tax . ': ' . $title . '</h1>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment