Output list of child terms from CPT Taxonomy with term images
-
Hi!
Just wondering if anyone can help with this – banging my head for days…
Wanting to output the children terms with images of the current term in CPT taxonomy in taxonomy_genre.php (I’m using the Taxonomy Image plugin)
The following code outputs all terms including parent terms.
$current_term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); $args = array( 'taxonomy' => $current_term->taxonomy, 'child_of' => $current_term->term_id, 'term_args' => array( 'orderby' => 'id', 'order' => 'ASC', 'hierarchical' => 0, ), ); $cats = apply_filters( 'taxonomy-images-get-terms', '', $args ); foreach ($cats as $cat) { echo '<li><a href="' . get_category_link($cat) . '" title="'. $cat->name .'">' ; echo wp_get_attachment_image( $cat->image_id, 'detail' ); echo $cat->name ; echo '</a></li>'; }
This code outputs the correct results but with no images – I’m trying to amalgamate the two, if you will.
$current_term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); $cats = wp_list_categories( array( 'child_of' => $current_term->term_id, 'taxonomy' => $current_term->taxonomy, 'hide_empty' => 0, 'hierarchical' => false, 'depth' => 2, 'title_li' => '' )); foreach ((array)$cats as $cat) { $catdesc = $cat->category_description; echo '<li><a href="'. get_category_link($cat).'" title="'. $cat->cat_name .'">'. wp_get_attachment_image( $cat->image_id, 'detail' ) . $cat->cat_name . '</a></li>'; }
- The topic ‘Output list of child terms from CPT Taxonomy with term images’ is closed to new replies.