Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save generatepress/b4b6642ac3b447c87a0440a59e1fdefb to your computer and use it in GitHub Desktop.
Save generatepress/b4b6642ac3b447c87a0440a59e1fdefb to your computer and use it in GitHub Desktop.
Change archive titles in GeneratePress
if ( ! function_exists( 'generate_archive_title' ) ) :
/**
* Build the archive title
*
* @since 1.3.24
*/
add_action( 'generate_archive_title','generate_archive_title' );
function generate_archive_title()
{
?>
<header class="page-header<?php if ( is_author() ) echo ' clearfix';?>">
<?php do_action( 'generate_before_archive_title' ); ?>
<h1 class="page-title">
<?php
if ( is_category() ) :
single_cat_title();
elseif ( is_tag() ) :
single_tag_title();
elseif ( is_author() ) :
/* Queue the first post, that way we know
* what author we're dealing with (if that is the case).
*/
the_post();
echo get_avatar( get_the_author_meta( 'ID' ), 75 );
printf( '<span class="vcard">' . get_the_author() . '</span>' );
/* Since we called the_post() above, we need to
* rewind the loop back to the beginning that way
* we can run the loop properly, in full.
*/
rewind_posts();
elseif ( is_day() ) :
printf( __( 'Day: %s', 'generatepress' ), '<span>' . get_the_date() . '</span>' );
elseif ( is_month() ) :
printf( __( 'Month: %s', 'generatepress' ), '<span>' . get_the_date( 'F Y' ) . '</span>' );
elseif ( is_year() ) :
printf( __( 'Year: %s', 'generatepress' ), '<span>' . get_the_date( 'Y' ) . '</span>' );
elseif ( is_tax( 'post_format', 'post-format-aside' ) ) :
_e( 'Asides', 'generatepress' );
elseif ( is_tax( 'post_format', 'post-format-image' ) ) :
_e( 'Images', 'generatepress');
elseif ( is_tax( 'post_format', 'post-format-video' ) ) :
_e( 'Videos', 'generatepress' );
elseif ( is_tax( 'post_format', 'post-format-quote' ) ) :
_e( 'Quotes', 'generatepress' );
elseif ( is_tax( 'post_format', 'post-format-link' ) ) :
_e( 'Links', 'generatepress' );
else :
_e( 'Archives', 'generatepress' );
endif;
?>
</h1>
<?php do_action( 'generate_after_archive_title' ); ?>
<?php
// Show an optional term description.
$term_description = term_description();
if ( ! empty( $term_description ) ) :
printf( '<div class="taxonomy-description">%s</div>', $term_description );
endif;
if ( get_the_author_meta('description') && is_author() ) : // If a user has filled out their decscription show a bio on their entries
echo '<div class="author-info">' . get_the_author_meta('description') . '</div>';
endif;
?>
<?php do_action( 'generate_after_archive_description' ); ?>
</header><!-- .page-header -->
<?php
}
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment