As you discovered, one possible solution is something like:
<?php $w_h = $w_d = 0; ?>
<?php while (have_posts()) : the_post(); ?>
<?php
if ( date('Yz') == get_the_time('Yz') ) {
if (!$w_d++) echo 'Today<br />';
} elseif ( date('Yz')-1 == get_the_time('Yz') ) {
if (!$w_h++) echo 'Yesterday<br />';
} else {
echo the_date();
};
?>
Related Posts:
- Get date of last update outside of loop
- Add 20yrs to post date, and then query
- Query date in wordpress loop
- Display date only once for a each set of posts relating to that date
- Loop through all posts in a certain year
- Show a different post every 3 days [duplicate]
- Group posts by date with a list
- Change date format
- Get last 5 days with posts
- wordpress showing all posts instead of date range
- Why did my most recent article fall behind an older one on my site?
- How to display Yoast SEO meta description in archive template for each post instead of the_excerpt()? [closed]
- How to get Author ID outside the loop
- remove tags from the_content
- the_title() shows title of the first post instead of the page title?
- Why do themes rely on “The Loop”?
- Endless loop with wp_insert_post and wp_update_post
- How do I prevent one of two multiple loops from repeating on a second page?
- Two custom loops, pagination, offset
- What exactly defines a Main Loop and a Secondary Loop?
- Loop code is displaying pages but not actual posts
- How are both HTTP and HTTPS versions displaying?
- Access to Media Library
- Getting two wp_link_pages output
- post loop causes wp_users and wp_usermeta DB queries for each users
- Ajax loop refresh on click
- wordpress loop and template files
- wordpress post loop in javascript
- Creating nested forum loops in bbPress [closed]
- Adding active/current class to get_terms list
- Loop through pages with specific template
- Loop starts from the beginning with second while loop on author.php
- Display posts from multiple user roles
- Display content of page template (get_page)
- Single page site (WordPress) including posts
- Meta Query with spaces in value?
- Display the_content on click jquery
- Missing image in gallery shortcode in custom feed
- Styling text and images in the_content()
- Including post thumbnail url in loop’s post object to reduce number of queries
- How do I use AJAX Query in my posts loop?
- Make blog page show 10 on first page, 9 on every other page
- Duplicate posts in paginated results
- Output loop leveraged shortcode twice on one page
- Posts active and expired in different loops
- Added if statement to loop
- How to get The Loop working with $wpdb->get_results()
- Pagination on Single Post
- Display Posts Only with Specific Tag
- How to get my loop to paginate?
- Add class to last 3 posts in loop
- Get author Meta for particular user inside the loop
- Will only show the first 10 wordpress posts instead of all my posts
- Foreach displays from last to first
- value of metadata is null wrong use of if statement
- Count post views in loop
- displaying recent comments outside loop without plugin
- get_the_ID not returning correct ID value
- Include future posts in tags and in search
- Separate First Post Loop
- add offset to archive page
- loop inside the foreach
- Category ID returns as ‘0’?
- make get_post work in the loop
- How to display 3 post per slide
- How to put a block of code between [shortcode][/shortcode] in do_shortcode()?
- current-user_can not working in loop
- For Each +1 WordPress Loop
- How can I access a post’s feature image outside the loop?
- Multiple loops for plugin
- How do I query based on the modified date?
- Skip 5 latest post while paging?
- WordPress: query pages except remove one page
- get_post_meta printing empty fields, but it shouldn’t be
- Is it possible to set archive.php instead of index.php to display blog?
- How to read taxonomy in loop?
- Undefined index: page in loop load ajax content
- how to add 4 post in one carousel slide
- Only Show Excerpt After First 3 Posts
- How to insert content before pagination in loop?
- Exclude Posts Using Meta Query and User Meta
- Is “the loop” a template tag?
- Deeply Nested Menu Loop with Twig using Timber [closed]
- WordPress redundant posts based on meta field
- WordPress with woocommerce custom query
- Get featured image outside the loop using foreach
- Page gets displayed in post field
- Active class for my flexslider in WordPress
- pre_get_posts main_query not displaying after applying tax_query filters
- setup_postdata in “loop-handling” php file called via $.ajax
- Secondary loop cuts off at 10 posts?
- Can’t see custom field after the Loop [closed]
- Same Loop on Multiple Pages
- get all page templates
- strange parse error when including a loop template within another template
- Previous Posts Link and Next Posts Link Show All The Same Articles?
- Posts Loops To Display Specific Posts Inside Page Template?
- Use callback function in AJAX pure javascript [closed]
- Undefined variable: woocommerce_loop [closed]
- title not being printed within html tag [closed]