Last active
September 19, 2019 06:07
-
-
Save thecodepoetry/f7b5c77ab4012caf32417d4b1e58fa3d to your computer and use it in GitHub Desktop.
list portfolio categories
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
| function dt_portoflio_category_list() { | |
| $terms = get_terms( array( | |
| 'taxonomy' => 'dt_portfolio_category', | |
| 'hide_empty' => true, | |
| ) ); | |
| $count = count( $terms ); | |
| if ( $count > 0 ) { | |
| $cats = '<ul>'; | |
| foreach ( $terms as $term ) { | |
| $cats .= '<li><a href="'.get_term_link($term->slug, 'dt_portfolio_category').'">' . $term->name . ' ('.$term->count.')</a></li>'; | |
| } | |
| $cats .= '</ul>'; | |
| } | |
| return $cats; | |
| } | |
| add_shortcode( 'dt_portoflio_category', 'dt_portoflio_category_list' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment