I'm showing published and future posts on a category page. I need to make future posts unclickable and add a special class to them in order to add a gray overlay, meaning the post is upcoming.. trying something like
$post_status = get_post_status($post_id);
if($post_status === 'future')
doen't work at all..How can I, inside the same loop, disable a link and add a class if post status is "future" ??
any help would be appreciated ..
Here is the first part of my loop (it's a premium theme, and I'm building a custom category page in a child theme)
$args = array(
'post_type'=> 'post',
'post_status' => array('publish','future'),
'showposts' => -1,
'category' => get_queried_object_id(), // Current category id
'category__in' => array( get_queried_object_id() )
);
$query= new WP_Query($args);
if ($query->have_posts()) :
while ( $query->have_posts() ) : $query->the_post();
$counter++;?>
<?php if( $counter % 2 == 0 ) :
if ('future'===get_post_status() ){
echo '<div class="td-pb-row future">';
}else if('publish'===get_post_status() ){
echo '<div class="td-pb-row">' ;
} ?>
<div class="td-pb-span6">
<h3 class="entry-title td-module-title">
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute() ?>">
<?php the_title() ?>
</a>
</h3>
<?php the_content();?>
</div>
<div class="td-module-image td-pb-span6">
<div class="td-module-thumb">
<?php
if ( current_user_can('edit_published_posts') ) {
edit_post_link('Edit', '', '', '', 'td-admin-edit');
}
?>
<a href="<?php the_permalink() ?>" rel="bookmark" class="td-image-wrap" title="<?php the_title_attribute() ?>">
<?php $post_thumbnail_url = '';
if( get_the_post_thumbnail_url(null, 'medium_large') != false ) {
$post_thumbnail_url = get_the_post_thumbnail_url(null, 'medium_large');
} else {
$post_thumbnail_url = get_template_directory_uri() . '/images/no-thumb/medium_large.png';
}
?>
<img class="entry-thumb" src="<?php echo esc_url($post_thumbnail_url) ?>" alt="<?php the_title() ?>" title="<?php echo esc_attr(strip_tags(the_title())) ?>" />
</a>
</div>
</div>
$post_id
?