is_new_day()WP 0.71

Whether the publish date of the current post in the loop is different from the publish date of the previous post in the loop.

For more information on this and similar theme functions, check out the Conditional Tags article in the Theme Developer Handbook.

Used By: the_date()

No Hooks.

Return

Int. 1 when new day, 0 if not a new day.

Usage

is_new_day();

Examples

0

#1 One post per group of posts published on the same day

An example of how you can use is_new_day() to display the inscription only once (for the first post) for all posts published on the same day.

The code is used inside the WordPress Loop:

if( is_new_day() ){
	echo "This post was not published on the same day as the previous one";
}

Notes

  • Global. String. $currentday The day of the current post in the loop.
  • Global. String. $previousday The day of the previous post in the loop.

Changelog

Since 0.71 Introduced.

is_new_day() code WP 6.4.3

function is_new_day() {
	global $currentday, $previousday;

	if ( $currentday !== $previousday ) {
		return 1;
	} else {
		return 0;
	}
}