-1

My code is this:

#http://localhost/wordpress/2015/04/01
if (is_day()) {
}
//Prints January, April, 2015
#http://localhost/wordpress/2015/04/
if (is_month()) {
    echo single_month_title(' ');
//prints April 2015
}
#http://localhost/wordpress/2015/
if (is_year()) {

}
//prints 2015

What I want is, when an user is previewing a month archive it will show him the current date he is viewing...

I can already print the monthly one successfully, what I do not know if is there a WordPress function already to print the current day the user is viewing or the current month?

2

Before Wordpress 4.1, you can show the date archive page titles with the following code: (Taken and slightly modified from the twentyfourteen theme)

if ( is_day() ) {
    printf( __( 'Daily Archives: %s', 'twentyfourteen' ), get_the_date() );

} elseif ( is_month() ) {
    printf( __( 'Monthly Archives: %s', 'twentyfourteen' ), get_the_date( _x( 'F Y', 'monthly archives date format', 'twentyfourteen' ) ) );

} elseif ( is_year() ) {
    printf( __( 'Yearly Archives: %s', 'twentyfourteen' ), get_the_date( _x( 'Y', 'yearly archives date format', 'twentyfourteen' ) ) );

} else {
    _e( 'Archives', 'twentyfourteen' );

}

As from Wordpress 4.1 you can use one of the following functions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.