I am trying to print my wordpress post into 2/2 grid but I think my div's are messed up.

    <div class="grid-container">
                                if ( has_post_thumbnail() ):
                                    echo '<div class="grid">'

                                        <?php the_post_thumbnail('medium_large');
                    <h1 class="page-sub-main-header" style="color: #00adee;">
                            <a href="<?php the_permalink(); ?>">
                                <?php the_title() ?>
                                <p><?php the_excerpt();?></p>
                                <div class="footer-meta">
                                    <a href="$query->the_permalink()"><?php the_category(); ?> </a>
                                    <span> <?php the_date('d/m/Y'); ?></span>
                                <?php endwhile;  ?>
                <?php endif;
                echo '</div>';
        </div><!--grid container-->

What am I doing wrong?

1 Answer 1


Remove the closing div after endif and Move it inside endwhile and the <div class="grid"> should be outside the post thumbnal check

  • thanks. it is always confusing. how to make sense of it so I don't do this again?
    – DCR97
    Commented Aug 3, 2018 at 10:30
  • You should have a basic understanding of layout if you can't get it then practice wireframing and flowcharts and give yourself a visual idea of the flow and view Commented Aug 3, 2018 at 10:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.