I have the following problem. I am using Advanced Custom Fields for Wordpress to create a subtitle field for a post. I like to give this subtitle some styling but my HTML code within the IF-statement doesn't show on the page. The $subtitle does show.
<?php $subtitle = the_field('subtitle'); ?>
<?php if(strlen(trim($subtitle)) > 0): ?>
<div class="post-sub-title"><?php $subtitle; ?></div>
<?php endif; ?>
I spent hours searching for similar problems but couldn't find any solutions. So this must probably be a rookie mistake on my part.
Solution
<?php $subtitle = get_field('subtitle'); ?>
<?php if(strlen(trim($subtitle)) > 0): ?>
<div class="post-sub-title"><?php $subtitle; ?></div>
<?php endif; ?>
Changed the_field() to get_field(). Kuddo's to Aditya Vikas!