Skip to main content

Check if post content is empty in WordPress (Solved)

If a WordPress page post content is empty, you might want to dynamically show or hide some other divs or design aspects of your website. Here is how you do it.


<?php $content = get_post()->post_content;
if(empty($content)):?>
  
 POST CONTENT IS EMPTY
                       
  
<?php else:?>


     <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

	<?php the_content(); ?>

     <?php endwhile; else: endif; ?>


<?php endif;?>

 

Leave a Reply