0

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">
            <?php
                if($query->have_posts()):
                        while($query->have_posts()):
                                $query->the_post();
                                if ( has_post_thumbnail() ):
                                    echo '<div class="grid">'
            ?>

                                        <?php the_post_thumbnail('medium_large');
                                endif;
                ?>
                    <h1 class="page-sub-main-header" style="color: #00adee;">
                            <a href="<?php the_permalink(); ?>">
                                <?php the_title() ?>
                                </a>
                        </h1> 
                                <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>
                                </div>
                                <?php endwhile;  ?>
                <?php endif;
                echo '</div>';
                ?>
        </div><!--grid container-->

What am I doing wrong?

1 Answer 1

0

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

2
  • 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.