Title: Blog Post looping incorrectly
Last modified: April 11, 2018

---

# Blog Post looping incorrectly

 *  [donrucastle](https://wordpress.org/support/users/donrucastle/)
 * (@donrucastle)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/blog-post-looping-incorrectly/)
 * Hi guys,
 * Just looking at a quick issue with a template. It is a basic blog template that
   is used to loop through blog posts and display them on the site in a grid format.
 * Unfortunately, it seems to be leaving weird gaps in-between the blog posts. I
   am assuming this is a looping issue where the loop is ending and then starting
   again? Or is this a clearfix issue?
 * I’d appreciate any help you could give!
 * Please see image attached:
 * > [View post on imgur.com](https://imgur.com/a/ga3gv)
 * Here is my template code:
 *     ```
       <section class="blog_sec clearfix">
       	<div class="container clearfix">
       		<div class="col-lg-8 col-sm-8 col-md-8 col-xs-12 blog_de clearfix">		
       			<?php
       			$args = array('post_type' => 'post','post_per_page'=>-1);
       			$the_query = new WP_Query( $args ); $i=0;
       			if ( $the_query->have_posts() ) {
       				while ( $the_query->have_posts() ) {
       					$the_query->the_post(); ?>
       			<div class="col-lg-6 col-sm-6 col-md-6 col-xs-12 blog_post_list">			
       			<div class="blog_imge">
       			<?php if ( has_post_thumbnail() ) : ?>
       				    <a>" title="<?php the_title_attribute(); ?>">
       					<?php $featured_img_url = get_the_post_thumbnail_url(get_the_ID(),'full'); 
       	echo '<img src="'.$featured_img_url.'" alt="" />';  ?>
       				    </a>
       				<?php endif; ?>
       			</div>			
       			<div class="blog_details">					
       				<h3><a>"><?php echo the_title();?></a></h3>
       				<div class="entry-meta">
       					<span class="entry-date"><?php echo get_the_date(); ?></span>
       				</div>
       				<div class="blog_ept"><?php $trimexcerpt = get_the_excerpt();	
       				$shortexcerpt = wp_trim_words( $trimexcerpt, $num_words = 10, $more = '… ' );
       				echo $shortexcerpt; ?></div>								
       			</div>
       			</div>
       			<?php $i++; }
       				wp_reset_postdata();
       ```
   
    -  This topic was modified 8 years, 1 month ago by [donrucastle](https://wordpress.org/support/users/donrucastle/).
      Reason: Included needed information
    -  This topic was modified 8 years, 1 month ago by [Jan Dembowski](https://wordpress.org/support/users/jdembowski/).

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/blog-post-looping-incorrectly/#post-10167930)
 * that is a formatting issue, with the simple floats not taking care of different
   heights of the containers…
 * please post a live link to your site to get help with the CSS.
 *  [helldog2018](https://wordpress.org/support/users/helldog2018/)
 * (@helldog2018)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/blog-post-looping-incorrectly/#post-10168331)
 * Hi [@donrucastle](https://wordpress.org/support/users/donrucastle/),
 * In style.css add:
    `.blog_post_list {height: 350px;}`
 * Let us know if this solves your issue.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Blog Post looping incorrectly’ is closed to new replies.

## Tags

 * [Blog](https://wordpress.org/support/topic-tag/blog/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 3 participants
 * Last reply from: [helldog2018](https://wordpress.org/support/users/helldog2018/)
 * Last activity: [8 years, 1 month ago](https://wordpress.org/support/topic/blog-post-looping-incorrectly/#post-10168331)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
