'loop problem in category.php page in wordpress when using "while (have_posts()) : the_post();"

I want to loop <div class="col-md-6"> using while (have_posts()) : the_post();> Problem is this loop create another <div class="col-md-6"> inside the first <div class="col-md-6">and I lost to create 2 column section. Below is my code

Getting this output:

<div class="col-md-6">
    <div class="col-md-6">
        Post 1 details
    </div>
    <div class="col-md-6">
        Post 2 details
    </div>
</div>

I want to get this output:

<div class="col-md-6">
    Post 1 details
</div>
<div class="col-md-6">
    Post 2 details
</div>



<section class="post-section">
        <div class="container">
            <div class="row">
                
                <?php if (have_posts()) : ?>
                <?php while (have_posts()) : the_post(); ?>
                <div class="col-md-6">
                    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
                    <small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></small>
                    <div class="entry">
                        <?php the_content(); ?>

                        
                    </div>

                    <?php endwhile; 

                    else: ?>
                    <p>Sorry, no posts matched your criteria.</p>


                    <?php endif; ?>
                </div>  
            </div>
        </div>
    </section>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source