Skip to content

Instantly share code, notes, and snippets.

@thecodepoetry
Last active September 19, 2019 06:07
Show Gist options
  • Select an option

  • Save thecodepoetry/f7b5c77ab4012caf32417d4b1e58fa3d to your computer and use it in GitHub Desktop.

Select an option

Save thecodepoetry/f7b5c77ab4012caf32417d4b1e58fa3d to your computer and use it in GitHub Desktop.
list portfolio categories
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