So you want to check if a field from acf has a value and if thats true you want to display it.
You can do it with this:
if( get_field( 'video' ) ) {
?>
<video width="320" height="240" controls>
<source src="https://wordpress.stackexchange.com/questions/292287/<?php echo get_field("video' ); ?>" type="video/mp4">
</video>
<?php
}else{
the_post_thumbnail('', array('class' => 'img-responsive'));
}
This checks the field with name ‘video’ for a value. If there is a value it will display the video. If there is no video it will display an image instead.
Here is the code added in your own code:
<?php
// the query
$the_query = new WP_Query( array(
'category' => 'Publish',
'category__not_in' => 36 ,
'orderby' => 'rand',
'order' => 'ASC',
'posts_per_page'=>'12'
));
?>
<div class="">
<?php if ( $the_query->have_posts() ) : ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<div class="col-md-4 col-sm-4 col-xs-12 reason">
<h2 class="postheader"><?php the_title(); ?>
</h2>
<a target="blank" href="https://wordpress.stackexchange.com/questions/292287/<?php the_field("url'); ?>"><?php
if( get_field( 'video' ) ) {
?>
<video width="320" height="240" controls>
<source src="https://wordpress.stackexchange.com/questions/292287/<?php echo get_field("video' ); ?>" type="video/mp4">
</video>
<?php
}else{
the_post_thumbnail('', array('class' => 'img-responsive'));
}?></a>
<br><?php the_excerpt(); ?> <a class="postlink" target="blank" href="https://wordpress.stackexchange.com/questions/292287/<?php the_field("url'); ?>">Read more</a>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php else : ?>
<p><?php __('No News'); ?></p>
<?php endif; ?>
</div>
You still need to change the ACF field name of ‘video’ in the code to your field name.