The is_day() WordPress PHP function determines whether the query is for an existing day archive.
Usage
if (is_day()) { // Your code here }
Parameters
- None
More information
See WordPress Developer Resources: is_day()
Examples
Display a special message on day archives
If you want to display a special message on day archive pages:
if (is_day()) { echo 'Welcome to the daily archive!'; }
Show a unique sidebar for day archives
To display a unique sidebar on day archive pages:
if (is_day()) { get_sidebar('day'); } else { get_sidebar(); }
Customize post layout for day archives
Customize the post layout for day archive pages:
if (is_day()) { get_template_part('content', 'day'); } else { get_template_part('content', 'regular'); }
Change the page title for day archives
Modify the page title on day archive pages:
if (is_day()) { $title = 'Daily Archive: ' . get_the_date(); } else { $title = 'Regular Archive'; } echo $title;
Apply custom CSS class for day archives
Add a custom CSS class to the body tag for day archive pages:
function add_day_body_class($classes) { if (is_day()) { $classes[] = 'day-archive'; } return $classes; } add_filter('body_class', 'add_day_body_class');