Created
November 16, 2016 04:01
-
-
Save jpen365/9aaf742a5f521a747bc84abe5b62a55a to your computer and use it in GitHub Desktop.
Iterate through all categories and break them into two columns
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
foreach( $categories as $category ) { | |
$cat_count ++; | |
$category_link = sprintf( | |
'<li class="list-unstyled"><a href="%1$s" alt="%2$s">%3$s</a></li>', | |
esc_url( get_category_link( $category->term_id ) ), | |
esc_attr( sprintf( __( 'View all posts in %s', 'textdomain' ), $category->name ) ), | |
esc_html( $category->name ) | |
); | |
if ($cat_count % 2 != 0 ) { | |
$cat_col_one[] = $category_link; | |
} else { | |
$cat_col_two[] = $category_link; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment