WordPress at a glance

is_month() WP 1.5.0

Determines whether a monthly archive page is shown (example.com/2009/08) — page with posts for a specific month. A conditional tag.

This function is a part of is_date() and is_archive() check, so if you use them together, you should use is_month() before those functions, otherwise is_month() condition will never occur.

Works based on: WP_Query::is_month()
1 time = 0.00007s = very fast | 50000 times = 0.02s = speed of light

No Hooks.


true/false. Whether the query is for an existing month archive.


if( is_month() ){
	// ...


#1 Display text only on monthly archive pages

if( is_year() ){
	echo 'This is a monthly archive page!';

#2 Use of is_archive() and is_month() together in if/else statements

if( is_month() )
	echo 'This is a monthly archive page!';
elseif( is_archive() )
	echo 'An archive page.';

So is_archive() should follow is_month(), otherwise is_month() condition will never occur.


  • Global. WP_Query. $wp_query WordPress Query object.


Since 1.5.0 Introduced.

Code of is_month() WP 5.6

function is_month() {
	global $wp_query;

	if ( ! isset( $wp_query ) ) {
		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
		return false;

	return $wp_query->is_month();

From tag: Conditional tags (page type and request)

More from tag: Conditional tags (all)

More from category: Queries

More from Template Tags: Main Functions

vladlu 100vlad.lu
Editors: Kama 100
No comments
    Log In