How can I style future post?

Just use the function get_post_status(). Inside the loop you have access to the Post Id, but if you leave this blank it will use the ID of the current post instead.

So you code will become something like this (not tested yet):

<h3 class="entry-title td-module-title">
    <?php if( get_post_status() != 'future' ) { ?>
    <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute() ?>">
        <?php the_title() ?>
    </a>
    <?php } else { ?>
        <?php the_title() ?>
    <?php } ?>
</h3>

The problem in your code might be with the $counter variable. The check for post status ‘future’ is only done for half of the posts, not for all of them, due to the % 2. So I think you should get rid of this $counter variable.

So to give an example of how you should change your code:

<?php if( 'future' == get_post_status() ){
    echo '<div class="td-pb-row future">';
} else {
    echo '<div class="td-pb-row">';
} ?>

Leave a Comment