WordPress.org

Support

Support » Plugins and Hacks » Taxonomy Images » [Plugin: Taxonomy Images] display children of current term only

[Plugin: Taxonomy Images] display children of current term only

  • Hi!

    Jsut 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.

    The following code outputs all terms including parent terms.

    my code:

    $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="'. strip_tags($catdesc) .'">'. $cat->cat_name . '</a><a href="' . get_category_link($cat) . '" title="'. $cat->name .'">' ;
    echo wp_get_attachment_image( $cat->image_id, 'detail' );
    echo $cat->name ;
    echo '</a></li>';
    }

    http://wordpress.org/extend/plugins/taxonomy-images/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Sorry – have removed the duplicated code.

    $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>';
    }

    Equally, this produces the correct result albeit without any images!

    $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>'; }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Taxonomy Images] display children of current term only’ is closed to new replies.
Skip to toolbar