If statement and concatenation

I’m trying to make a slight adjustment to a wordpress template. I basically only want the code below to print if the_content() is empty. Currently, if it’s empty, it still generates the article aka an ugly white box. I’ve been trying to put the code into a string and just do an if statement on the string, but concatenating all this code into a string isn’t working for me. Any suggestions? Simpler way to do what I want to do, or is a concatenated string the best way? If so, can I get help putting this all into a string? THANKS!

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <?php if ( '' != get_the_post_thumbnail() ) : ?>
        <div class="entry-thumbnail">
            <?php the_post_thumbnail( 'featured-image' ); ?>
        </div><!-- .entry-thumbnail -->
    <?php endif; ?>

    <header class="entry-header">
        <h1 class="entry-title"><?php the_title(); ?></h1>
    </header><!-- .entry-header -->

    <div class="entry-content">
        <?php the_content(); ?>
        <?php
            wp_link_pages( array(
                'before'   => '<div class="page-links">',
                'after'    => '</div>',
                'pagelink' => '<span class="page-link">%</span>',
            ) );
        ?>
    </div><!-- .entry-content -->
    <?php edit_post_link( __( 'Edit', 'singl' ), '<footer class="entry-meta"><span class="edit-link">', '</span></footer>' ); ?>
</article>

Related posts

Leave a Reply

1 comment

  1. <?php
    $content = get_the_content();
    if($content != '') { 
        the_content(); 
    } ?>
    

    or

    <?php if( $post->post_content != "" ) {
        //do something or show content
    }