How to Display Today and Tomorrow Instead of Post Dates
-
I seem to always get stuck working with dates and I can’t get this query to work properly. I’m still learning how to write these queries, so thanks for your patience.
Here’s what I’d like (this is for displaying Posts tagged as events)
– If a custom field is filled in, I’d like it to display the contents of the custom field.
However, if the custom field is blank, I’d like it to do the following, but only if the parent category is events:
– If the post’s date is today’s date, then I would like it to say Today
– If the post’s date is tomorrow’s date, then I would like it to say Tomorrow
– If the post’s date is neither, I’d like it to just display the dateThanks for your help!
<?php $postDate = strtotime( $post->post_date ); $todaysDate = time() - (time() % 86400); $tomorrowsDate = time() - (time() % 172800); $eventtext = get_post_meta($post->ID, '_ct_text_4e3318cbab83d', true); if($eventtext) : echo get_post_meta( $post->ID, '_ct_text_4e3318cbab83d', true ); elseif( $eventtext == '' || (is_category_or_sub(events)) || $postDate == $todaysDate ) : echo "Today"; elseif( $eventtext == '' || (is_category_or_sub(events)) || $postDate == $tomorrowsDate ) : echo "Tomorrow"; else( $eventtext == '' || (is_category_or_sub(events)) ) : echo the_date('M j', '', ''); endif; ?>
- The topic ‘How to Display Today and Tomorrow Instead of Post Dates’ is closed to new replies.