<?php $terms = get_terms('categories'); foreach ( array_reverse($terms) as $term ) { //$cat = get_field('sub_category', $term); ?> <div class="title orangeText mb-4"><?php echo $term->name; ?></div> <div class="row row-cols-lg-4 row-cols-md-3 row-cols-sm-2 row-cols-1 gx-4"> <?php $args = array( 'post_type' => 'industries', // Replace 'your_post_type' with the actual name of your post type 'posts_per_page' => -1, // Retrieve all posts 'order' => 'ASC', 'tax_query' => array( array( 'taxonomy' => 'categories', 'field' => 'slug', 'terms' => $term->slug, ), ), ); $query = new WP_Query($args); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); ?> <div class="col mb-5 animateThis slideTop"> <div class="investorBox indlBox h-100"> <div class="imgBox"> <img src="<?php the_field('industry_image'); ?>" alt=""> </div> <h3><?php the_title(); ?></h3> <p><?php the_excerpt(); ?></p> <div class="indlBtn"> <p class="ctaBtn mt-4"><span>Read More</span></p> </div> <a href="<?php the_permalink(); ?>" class="stretched-link"></a> </div> </div> <?php } wp_reset_postdata(); } else { // No posts found } ?> </div> <?php } ?>
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter