Created
February 8, 2016 04:44
-
-
Save hsleonis/43b2eb3a7bc9cb6ffe6f to your computer and use it in GitHub Desktop.
Print list of all terms of a given taxonomy with link
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 | |
$args = array( 'hide_empty=0' ); | |
$terms = get_terms( 'status', $args ); | |
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) { | |
$count = count( $terms ); | |
$i = 0; | |
$term_list = '<ul class="spec-project-cat-ul">'; | |
foreach ( $terms as $term ) { | |
$i++; | |
$term_list .= '<li class="col-xs-4 remove-padding"><a href="' . esc_url( get_term_link( $term ) ) . '" alt="' . esc_attr( sprintf( __( 'View all %s projects', 'themeaxe' ), $term->name ) ) . '">' . $term->name . '</a></li>'; | |
if ( $count != $i ) { | |
$term_list .= ''; | |
} | |
else { | |
$term_list .= '</ul>'; | |
} | |
} | |
echo $term_list; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment