Is it possible to only show posts that have todays date or in the future? I don’t want to show any posts that are in the past.
Also, I want the list to show posts that have a date in the future as in the CMS it shows as scheduled.
Here’s my loop:
<div class="news-content" style="background-color:#feefe7!IMPORTANT;">
<div class="page-title-content">
<h2><?php echo the_title(); ?></h2>
</div>
<div class="news-content-inner">
<?php $portfolioloop = new WP_Query(array(
'paged' => get_query_var('paged'),
'post_type' => 'news',
'posts_per_page' => 4,
'tax_query' => array(
array(
'taxonomy' => 'news',
'field' => 'id',
'terms' => 51,
),
),
)); ?>
<?php while ( $portfolioloop->have_posts() ) : $portfolioloop->the_post(); ?>
<div class="news-item" onClick="location.href='<?php echo the_permalink(); ?>'">
<h2><a style="color:#F45B11!IMPORTANT;" href="<?php echo the_permalink(); ?>"><?php echo the_time('d.m.Y'); ?> / <?php echo the_title(); ?></a></h2>
<p class="news-page">
<?php if (get_field('description') != "") { ?>
<?php echo the_field('description'); ?>
<?php } else {
$newscontent = get_the_content();
$newscontent_str = strip_tags($newscontent, '');
echo substr($newscontent_str,0,250) . "â¦";
} ?>
</p>
</div>
<?php endwhile; // end of the loop. ?>
<p class="news-page" style="font-size:12px!IMPORTANT;"><?php echo $portfolioloop->post_count; ?> opportunities</p>
<?php if (function_exists('wp_pagenavi')) {
wp_pagenavi( array( 'query' => $portfolioloop ) ); } ?>
</div>
</div>
Can’t believe I didn’t see this sooner, simply solved it with this in the query:
'post_status' => 'future'
So once published it just disappears from the list.
As described here, you could add an additional filter to your query.
In your case that means the following: