Skip to content

Instantly share code, notes, and snippets.

@ChrisCree
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisCree/9962113 to your computer and use it in GitHub Desktop.
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.
<?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>';
}
}
<?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