I have the following conditional that is only partially working. It DOES correctly display the content or excerpt if they contain data, but the echo statements do not display. I can place the echo '<h3>... or echo '<div>... outside of the conditional (above or below) and they will display fine.
Using Firebug I have verified whether or not they are outputting.
echo outputs nothing:
<?php if (the_content()) : ?>
<?php echo '<h3 style="font-weight: 300;">CONTENT</h3>'; ?>
<?php the_content(); ?>
<?php echo '<div class="fullwidth_bg" style="height: 20px;"></div>'; ?>
<?php elseif (the_excerpt()) : ?>
<?php echo '<h3 style="font-weight: 300;">EXCERPT</h3>'; ?>
<?php the_excerpt(); ?>
<?php echo '<div class="fullwidth_bg" style="height: 20px;"></div>'; ?>
<?php endif; ?>
echo outputs as expected:
<?php echo '<h3 style="font-weight: 300;">CONTENT</h3>'; ?>
<?php if (the_content()) : ?>
<?php the_content(); ?>
<?php elseif (the_excerpt()) : ?>
<?php the_excerpt(); ?>
<?php endif; ?>
<?php echo '<div class="fullwidth_bg" style="height: 20px;"></div>'; ?>
Why are the echo statements not outputting inside of the first conditional above?
if (the_content())returns true and displays the page content if it contains data... I mean, how can <?php the_content(); ?>` get executed and pass right by the<h3>without it getting displayed with theecho?iflines and not inside theifconditionals. I'll check my conditional logic and comment back.if (get_the_content() == "")...- a big oversight. My logic was wrong but you both helped me identify it. Please enter an answer and I will mark it correct. :S