Last active
August 29, 2015 13:58
-
-
Save ChrisCree/9962113 to your computer and use it in GitHub Desktop.
Code to display the name of a category/tag/taxonomy as the title of an archive page in the Genesis framework.
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 | |
// Display Category Title | |
remove_action( 'genesis_before_loop', 'genesis_do_taxonomy_title_description', 15 ); | |
add_action( 'genesis_before_loop', 'genesis_do_custom_title_description', 15 ); | |
function genesis_do_custom_title_description() { | |
if ( is_category() || is_tag() || is_tax() ) { | |
echo '<div class="archive-description taxonomy-description"> <h1>' . get_queried_object()->name . '</h1></div>'; | |
} | |
} |
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 | |
// The code below only works for Categories and should not be used | |
// Display Category Title | |
remove_action( 'genesis_before_loop', 'genesis_do_taxonomy_title_description', 15 ); | |
add_action( 'genesis_before_loop', 'genesis_do_custom_title_description', 15 ); | |
function genesis_do_custom_title_description() { | |
if ( is_category() || is_tag() || is_tax() ) { | |
$current_cat_id = get_query_var( 'cat' ); | |
echo '<div class="archive-description taxonomy-description"> <h1>' . get_cat_name( $current_cat_id ) . '</h1></div>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment