In WordPress, is_new_day() is used inside The Loop. It returns 1 (true) when the current post was published on a different calendar day than the previous post. Otherwise it returns 0 (false).
It is used to print a date heading once for each day, instead of printing the same date above every post.
Syntax
Use it as the test of an if statement.
WordPress
if ( is_new_day() ) {
// code for the true path
} else {
// code for the false path
}
Call
What it does
is_new_day()
True (1) for the first post of a new day.
the_date()
Prints the date only once per day. It uses the same idea.
! is_new_day()
True when the post is on the same day as the one before.
Posts are shown in date order, so posts of the same day appear together.
Full declaration
WordPress
is_new_day(): int
Parameters
Parameter
Description
None
This function takes no parameters.
Return Value
Return Value
Description
int
1 if the current post is on a new day, otherwise 0. Both work in an if.
WordPress Examples
Three short theme examples. Each one shows what prints on the true path and the false path.