Conditional on has_post_thumbnail

2

Well I'm setting up a theme that some posts will be displayed a thumb and some not, but I need to put a conditional on the code that when it has thumb pull the config of thumb and when it does not have a simple post. However the current way it is trying to pull just the way it has thumb

Here is the code with the configuration:

<div class="container">
    <div class="row">

        <!-- Main Content -->
        <div class="col-md-9 border-right">

            <div class="main-content" id="main">

                <div class="row">
                    <div class="col-md-12">
                        <div class="text-content center">
                            <?php the_content(); ?>
                        </div>
                    </div>
                </div>

                <ul class="result-list">
                    <?php 
                        $paged = get_query_var('paged');
                        query_posts('category_name=saude-caixa&paged='.$paged);
                    ?>
                    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

                        <article class="blog-item-list">
                        <li class="result-item">
                            <div class="text-content">
                        <?php if(has_post_thumbnail($post->ID)); ?>
                                <div class="entry-image">
                                <img src="<?php the_post_thumbnail_url($post->ID, 'ag-apcef-large'); ?>" alt="<?php the_title(); ?>">
                                </div>

                                <a href="<?php the_permalink() ?>"><h2><?php the_title(); ?></h2></a>
                                <div class="entry-meta">

                                    <span class="entry-date"><i class="fa fa-clock-o"></i> <time><?= get_the_date(); ?></time></span>
                                </div>
                                <?php the_excerpt() ?>
                                <a href="<?php  the_permalink(); ?>" class="link">Ler Tudo</a>
                            </div>
                        </li>
                        </article>

                    <?php endwhile; endif;?>
                </ul>

                <?php

                the_posts_pagination( array(
                    'mid_size'  => 2,
                    'prev_text' => false,
                    'next_text' => false,
                    'screen_reader_text' => ' '
                ) );

                ?>

            </div>

        </div>

        <!-- Sidebar -->
        <div class="col-md-3" id="sidebar">
            <?php get_sidebar(); ?>
        </div>
    </div>
    
asked by anonymous 01.08.2017 / 21:29

1 answer

1

It's missing closing the if where you check if the thumbnail exists:

<?php if(has_post_thumbnail($post->ID)) : ?>
    <div class="entry-image">
        <img src="<?php the_post_thumbnail_url($post->ID, 'ag-apcef-large'); ?>" alt="<?php the_title(); ?>">
    </div>
<?php endif; ?>
    
01.08.2017 / 22:03