Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. <?php
  2. $term_id = get_queried_object()->term_id;
  3. $taxonomy_name = get_query_var( 'cat' );
  4. $termchildren = get_term_children( $term_id, $taxonomy_name );
  5.  
  6. // Loop through each child taxonomy term
  7. foreach ( $termchildren as $child ) {
  8. // Get the term object
  9. $term = get_term_by( 'id', $child, $taxonomy_name );
  10.  
  11. // Get the values we need to output
  12. $url = get_term_link( $child, $taxonomy_name );
  13. $name = $term->name;
  14.  
  15. // We make the call here to get the image and we pass in the term we want the image for
  16. $image = get_field('kategorija_slika', $term );
  17.  
  18. // Output it all
  19. echo '<div class="col-sm-4 sub-caregory">';
  20. echo '<a href="' . $url . '">' . $name . '</a><div class="sub-caregory-image"><img src="' . esc_url($image['url']) . '" alt="' . esc_attr($image['alt']) . '" /></div>';
  21. echo '</div>';
  22. }
  23. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement