3 Grid Loop in WordPress Code using Bootstrap

 
<div class="row">
<?php if (have_posts()): while (have_posts()) : the_post(); ?>
<div class="col-lg-4 col-sm-6 my-4">
	<div class="featured_box">
	<!-- article -->
	<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

		<!-- post thumbnail -->
		<?php if ( has_post_thumbnail()) : // Check if thumbnail exists ?>
			<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
				<?php the_post_thumbnail('custom-size'); // Declare pixel size you need inside the array ?>
			</a>
		<?php endif; ?>
		<!-- /post thumbnail -->

<figcaption>
		<!-- post title -->
		<h2 class="featured_h2">
			<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
		</h2>
		<!-- /post title -->
</figcaption>
		<!-- post details -->
	<p class="index_excerpt"><?php
echo wp_trim_words( get_the_content(), 13, '...' );
?></p>

	</article>
	<!-- /article -->
</div></div>
<?php endwhile; ?>

<?php else: ?>
</div>
	<!-- article -->
	<article>
		<h2><?php _e( 'Sorry, nothing to display.'); ?></h2>
	</article>
	<!-- /article -->

<?php endif; ?>

Leave a Reply

Your email address will not be published. Required fields are marked *