WordPress.org

Ready to get started?Download WordPress

Forums

Show month/year in archive title (3 posts)

  1. gulliver
    Member
    Posted 2 years ago #

    How do I show the year and month in the header <title> of archives?

  2. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    some useful code is at the top of archive.php of Twenty Ten;

    simplified and re-written for use in header.php for the <title>:

    <?php if ( have_posts() ) 	the_post();
    if ( is_month() ) : echo get_the_date( 'F Y' );
    elseif ( is_year() ) : echo get_the_date( 'Y' );
    rewind_posts(); ?>

    http://codex.wordpress.org/Conditional_Tags

  3. gulliver
    Member
    Posted 2 years ago #

    Thanks. I'll look and adapt what I can.

    The problem arose because I'd used conditional titles, and had incorrectly coded with the effect of removing the year/month on archives, and just couldn't see how to re-add them.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.