How to display custom taxonomy in multiple columns?

I have a custom taxonomy (with terms that include all 50 states) that I’m displaying, along with the title of the posts in that term directly below. Simple, and it’s working as expected. However, right now, it’s just a long list of all the terms/posts. Instead of this long list, I’d like it to display in 3 columns. Can anyone help?

function custom_do_grid_loop() {

     echo '<div class="group-list">';

     $custom_terms = get_terms('states');

     foreach($custom_terms as $custom_term) {
         wp_reset_query();
         $args = array('post_type' => 'local_groups',
             'tax_query' => array(
                 array(
                     'taxonomy' => 'states',
                     'field' => 'slug',
                     'terms' => $custom_term->slug,
                     'orderby' => 'title',
                     'order'   => 'DESC',
                 ),
             ),
          );

          $loop = new WP_Query($args);

          if($loop->have_posts()) {

            echo '<div class="group-wrap">';

             echo '<p>'.$custom_term->name.'</p>';

             while($loop->have_posts()) : $loop->the_post();
                 echo '<a href="'.get_permalink().'">'.get_the_title().'</a><br>';
             endwhile;

             echo '</div>';

          }

    }

        echo '</div>';

    }

0

Leave a Comment