I have a list of 'post_status'' => 'future' which are published at certain dates throughout the year. These posts are custom posts whith Advanced Custom Fields.

Since a couple of days I'm trying to display "Today" of published posts (for that particular day). The word "Today" should only display if date of the post equals the current date otherwise the the scheduled posts should be displayed.

The query which looks like this display future posts:

 $future= new WP_Query(array(
    'post_type' => 'hijama_days',
    'date' => date('d/m/Y'),
    'posts_per_page' => 1,
    'order' => 'ASC',
    'post_status' => 'future',

The loop looks like this:

while ( $future->have_posts() ) : $future->the_post();

// next line is from Advanced Custom Field Docs
$gdate = DateTime::createFromFormat('Ymd', get_field('gregorian_date'));

I've tried this to display "Today" when the current event has been pusblished for that day:

$currentdate = new DateTime();

<p>When is the next event date?</p>
<?php if( $gdate->format('d/m/Y') == $currentdate->format('d/m/Y') ){ ?>
<?php } else { ?>
   <h1><?php echo $gdate->format('l') . ' '; the_title(); ?></h1>
<?php } ?>
   <h4>Gregorian: <?php echo $gdate->format('d/m/Y'); ?></h4>

Somehow I cannot figure why is not working for me.

Please help me out here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.