loop starts to nest content randomly
-
I have this template:
<?php $args = array( 'posts_per_page' => 12, 'post_type' => 'post', 'orderby' => 'rand' ); $more_query = new WP_Query($args); if($more_query->have_posts()): $counter = 1; ?> <div class="row cc-row editorial__block"> <?php while($more_query->have_posts()): $more_query->the_post(); ?> <?php get_template_part('layouts/card', 'card__3-1'); ?> <?php endwhile; ?> </div> <?php endif; ?> <?php wp_reset_query(); ?>
which calls this template:
<div class="col-4"> <div class="card card__3-1"> <a href="<?php echo the_permalink();?>" class="block__link"></a> <div class="card__image" style="background-image:url('<?php echo the_post_thumbnail_url('large-feature'); ?>')"></div> <div class="card__category-block"> <div class="<?php echo get_post_icon_class(); ?>"></div> <div class="card__category-block__category-details"> <div class="card__category-block__category-type"> <?php echo get_category_type_title();?> </div> <div class="card__category-block__category-info"> <?php echo get_category_type_subject(); ?> </div> </div> </div> <div class="card__category-line"></div> <div class="card__filter"></div> <div class="card__body"> <div class="card__copy"> <div class="card__title"> <?php echo get_card_title(); ?> </div> <div class="card__text"> <?php echo get_card_excerpt(); ?> </div> </div> </div> </div> </div>
The problem is after about the 4th or 5th element they start to nest into each other in the output. It’s never consistent sometimes it works mostly it doesn’t. How do implement this so it works.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘loop starts to nest content randomly’ is closed to new replies.