How to get category and archive title?

For category use single_cat_title function:
http://codex.wordpress.org/Function_Reference/single_cat_title

For tag use single_tag_title function:
http://codex.wordpress.org/Function_Reference/single_tag_title

For date use get_the_date function:
http://codex.wordpress.org/Function_Reference/get_the_date

For example if you open twentyten theme you will see following:

category.php:

<h1 class="page-title"><?php
    printf( __( 'Category Archives: %s', 'twentyten' ), '<span>' . single_cat_title( '', false ) . '</span>' );
?></h1>

date.php:

<h1 class="page-title">
    <?php if ( is_day() ) : ?>
        <?php printf( __( 'Daily Archives: <span>%s</span>', 'twentyten' ), get_the_date() ); ?>
    <?php elseif ( is_month() ) : ?>
        <?php printf( __( 'Monthly Archives: <span>%s</span>', 'twentyten' ), get_the_date( _x( 'F Y', 'monthly archives date format', 'twentyten' ) ) ); ?>
    <?php elseif ( is_year() ) : ?>
        <?php printf( __( 'Yearly Archives: <span>%s</span>', 'twentyten' ), get_the_date( _x( 'Y', 'yearly archives date format', 'twentyten' ) ) ); ?>
    <?php else : ?>
        <?php _e( 'Blog Archives', 'twentyten' ); ?>
    <?php endif; ?>
</h1>

Leave a Comment