Nested wordpress without duplicate message

I want the loop to show a total of 16 messages about the differences, it will be divided by 4 times. Seconds x4 will show 1 message each, for a total of 4 messages in 1. The message is not duplicated! Plz help me!

<div class="slide-start fl col-lg-12 clear"> <!-- start 1st loop here, big loop to get totals 16 posts --> <div class="groupitem"> <!-- start 2nd loop here to get 4 posts --> <div class="g-item fl"> <a class="fl clear col-lg-12 pro-img" href=""><?php the_post_thumbnail('medium');?></a> <a class="fl clear col-lg-12 pro-tit" href=""><?php the_title() ;?></a> <span class="fl clear col-lg-12 pro-type">Hair</span> <p class="fl clear col-lg-12 pro-price"><span>105</span> USD <span>(0.5</span> KG)</p> </div> </div> </div> 
+4
source share
1 answer

Something like this should work:

 <?php $args = array('posts_per_page' => 16); $posts = get_posts($args); $rows = array_chunk($posts, 4); ?> <div class="slide-start fl col-lg-12 clear"> <?php foreach($rows as $row): ?> <div class="groupitem"> <?php foreach($row as $post): setup_postdata($post); ?> <div class="g-item fl"> <a class="fl clear col-lg-12 pro-img" href=""><?php the_post_thumbnail('medium');?></a> <a class="fl clear col-lg-12 pro-tit" href=""><?php the_title() ;?></a> <span class="fl clear col-lg-12 pro-type">Hair</span> <p class="fl clear col-lg-12 pro-price"><span>105</span> USD <span>(0.5</span> KG)</p> </div> <?php endforeach; ?> </div> <?php endforeach; wp_reset_postdata(); ?> </div> 
0
source

All Articles