Skip to content

Instantly share code, notes, and snippets.

@jamiemitchell
Created May 26, 2013 06:35
Show Gist options
  • Select an option

  • Save jamiemitchell/5651901 to your computer and use it in GitHub Desktop.

Select an option

Save jamiemitchell/5651901 to your computer and use it in GitHub Desktop.
/**
* Auto-generate taxonomy title for archive pages
*
* Will say "[Term] Archives"
*
*/
add_action( 'genesis_before_loop', 'ac_do_taxonomy_title_description', 20 );
function ac_do_taxonomy_title_description() {
global $wp_query;
if ( ! is_category() && ! is_tag() && ! is_tax() )
return;
if ( get_query_var( 'paged' ) >= 2 )
return;
$term = is_tax() ? get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ) : $wp_query->get_queried_object();
if ( ! $term || ! isset( $term->meta ) )
return;
$headline = '';
// If we have a headline already, then return, otherwise auto-generate
if ( $term->meta['headline'] )
return;
else {
$headline = sprintf( '<h1>%s Archives</h1>', single_term_title( '', false ) );
printf( '<div class="taxonomy-description">%s</div>', $headline );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment