• 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

    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. Reason: Included needed information
    • This topic was modified 8 years, 1 month ago by Jan Dembowski.
Viewing 2 replies - 1 through 2 (of 2 total)
  • 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.

    Hi @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.