Created
July 20, 2016 06:40
-
-
Save generatepress/cc2d8b578c8c3706dcefe68234ca5c9f to your computer and use it in GitHub Desktop.
show the category description only on the first page, generate_archive_title()
This file contains 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
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(); | |
$page = (get_query_var('paged')) ? get_query_var('paged') : 1; | |
if ( ! empty( $term_description ) && $page == 1 ) : | |
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