Let CSS handles the grid layout.
For example with markup like this:
<ul class="term-list">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
</ul>
You can create that layout simply with this CSS:
.term-list {
display: grid;
grid-template-columns: repeat(3, minmax(0,1fr));
column-gap: 1rem;
grid-gap: 1rem;
}
So just abandon the custom counter and each loop only append the <li>
.
foreach( $groups as $letter => $tags ) {
$list .= '<div><h3>' . $letter . '</h3> <ul>';
foreach( $tags as $tag ) {
$list .= '<li><a href="/brand/'.$tag->slug.'">'.$tag->name.'</a></li>';
}
$list .= '</ul></div>';
}
Related Posts:
- Sort on meta value but include posts that don’t have one
- Using Orderby and meta_value_num to order numbers first then strings
- multiple orderby in pre_get_posts action
- get_the_terms in descending alphabetical order
- next and previous post link ordered alphabetically
- Order posts by meta_value even if meta_key is not filled
- Order by first name
- How to alter query order direction using $query->set(‘order’, ‘ASC’); inside a pre_get_posts filter?
- the_tags() : display the tags by the order they are typed in in the backend, not alphabetically
- Sorting Attributes order when using get_the_terms
- How to order posts by meta value?
- How Do I Order Posts by Modified Date? [duplicate]
- Orderby Post Views
- How to order posts (woocommerce products) alphabetically but ignore certain words, eg ‘The’ and ‘An’
- How to order posts by alphabet with numbers at the end
- Best Plugin to Reorder Post Types
- Ordering system through WordPress
- Issue with multiple orderby values
- get_query_var returns wrong default value
- Use pre_get_posts to sort meta_key by an array of values
- Show first the posts from 1 specific tag
- Order posts by price
- All, published and pending order
- get_adjacent_post() returning weird results
- Get_Users Orderby Page
- Sort order of next/prev sibling page
- Order char by post title
- Why does pre_get_posts() return “date” as the orderby parameter for every sortable column?
- next_post_link and previous_post_link order not working properly
- query pages by a childs publish date
- List most recently added posts (with a twist)
- Check post_date in pre_get_posts
- pre_get_posts shows posts in random order sometimes
- Featured-Content/Featured Posts With Random Order
- Orderby in Query Posts affected by operating system?
- Ordering posts by title containing numbers
- Stylesheet Enqueue Order and Best Practices
- wp_list_pages sort order by top nav menu order and child of
- How to display taxonomy terms the way they are hierarchical
- wp_list_categories() by alphabet? (ex. only category titles that start with “A”) [closed]
- Order by ASC, DESC, Title, Date from URL on custom page template post
- Offset posts with random order
- view subcategories order by id
- Sort query output on taxonomy term archive by post type using pre_get_posts
- ASC and DESC separately from orderby
- Order WP_Query by The Order of an Array in Tax_Query
- struggling to order by title
- Order by two meta values – one is a number and the other is text
- Last post sorting get_categories
- Sort by DESC works, ASC doesn’t?
- Shop sends Mail with order cancellation
- update_post_meta saves data but does not show in Order backend
- Changing cache update rate
- how to complete order status automatically after paypal payment received
- Order management including recurring orders on woocommerce
- Orderby Title not working
- Sort loop by title doesn’t sort single digits like human would
- Sort posts by meta value with get method
- How to order custom user list columns by datetime?
- Creating a post that contains a list of other posts like a table of contents
- Want to order by Meta Values (tweaking Post Order Widget)
- Changing posts order on a page
- Ordering Subcategories
- How to order posts by parents?
- single post navigation order (NOT chronological)
- Problem with meta_value order after update
- Random order of posts on each request
- How can I make have_posts() return posts ordered DESC by id?
- Add post order like page order
- Woocommerce Pre Orders view order link wrong [closed]
- How to make WordPress orderby work with post_excerpt column?
- Orderby with menu_order and title
- Sort wordpress posts by facebook likes [closed]
- Sorting by date not working?
- Query posts from current year
- WP REST API: Order posts by meta value (acf)?
- Compare 3 custom fields and sort by oldest
- Order Custom post type loop by custom field (datepicker)
- Show all parents and children in custom post type in right order
- wp_enqueue_script order – external vs inline js
- Change Order of Admin Posts Depending on Meta
- How to order separated Custom Post Search results
- How can I sort posts by the date and a custom meta field?
- How to orderby multiple meta fields if some fields are empty
- How to redefine the sorting of product categories by menu_order?
- Display Woocommerce Orders for specific author [closed]
- I want to Add My Product Image to Admin Order Email in Woocommerece [closed]
- Where is the order of a menu saved in the database
- How can I add a box to edit Order on a regular post?
- How do order product categories – on a parent category page – in Woocommerce?
- Order custom fields alphabetically
- What’s wrong with this meta query? (order by meta key, then title, doesn’t work)
- WP_Query random ordering not working since 5.4
- How to save one API response to WooCommerce order meta data
- SEARCH QUERIES – REVERSE OUTPUT
- Display three sequential posts on each page load, without repeating previous
- Find by post_meta, then sort by post_meta, then sort by date (wp_posts)
- $args Orderby The number
- How to search for articles containing two words?
- Query order by meta value force specific tag first