Skip to content

Instantly share code, notes, and snippets.

@Aziz-Rahman
Created February 2, 2015 04:52
Show Gist options
  • Save Aziz-Rahman/383c49734f77db559cb1 to your computer and use it in GitHub Desktop.
Save Aziz-Rahman/383c49734f77db559cb1 to your computer and use it in GitHub Desktop.
Get Terms Taxonomy in Wordpress
<?php
// Select taxonmony
$taxonomies = array(
'kb_category',
);
// Filter taxonomy
$args = array(
'hide_empty' => false,
);
// Get taxonomy data
$terms = get_terms( $taxonomies, $args );
// Loop each taxonomy
foreach( $terms as $catsid ) :
if( $catsid ) :
$args = array(
'type' => 'post',
'hide_empty' => 0,
'hierarchical' => 0,
'taxonomy' => 'kb_category',
'pad_counts' => false
);
$mycats = get_categories( $args );
$taxonomy = 'kb_category';
$term = get_term( $catsid, $taxonomy );
$term_name = $term->name;
$term_slug = $term->slug;
$term_count = $term->count;
?>
<!-- Data ditampilkan -->
<?php echo $term_name; ?><span class="article-count"><?php echo $term_count; ?> <?php _e('articles', 'nama_theme'); ?></span>
<!-- Etc Data ( dll ) -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment