Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. <?php
  2. $taxonomy = 'product';
  3. $args = array(
  4. 'pad_counts' => true,
  5. 'hide_empty' => false
  6. );
  7. $terms = get_terms( $taxonomy , $args );
  8. if ( count( $terms ) != 0 ) {
  9. echo '<ul>';
  10. foreach ( $terms as $term ) {
  11. $term = sanitize_term( $term, $taxonomy );
  12. $term_link = get_term_link( $term, $taxonomy );
  13. if ( is_wp_error( $term_link ) ) {
  14. continue;
  15. }
  16. if( $term->parent != 0 ) {
  17. echo '<li class="children">';
  18. } else {
  19. echo '<li>';
  20. }
  21. echo '<a href="' . esc_url( $term_link ) . '">' . $term->name . '</a>(' . $term->count . ')';
  22. echo '</li>';
  23. }
  24. echo '</ul>';
  25. }
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement