WordPress.org

Ready to get started?Download WordPress

Forums

Taxonomy Images
[resolved] Taxonomy children images. (3 posts)

  1. sablednah
    Member
    Posted 2 years ago #

    I'm trying to get all the attached images for children of the current taxonomy. They're going into a slider with names links and descriptions so I really need an array of result information.

    So far I have this...

    $header_term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
    $header_args = "";
    
    if ($header_term) {
    	if ($header_term->parent == 0) {
    		$header_args = array ('taxonomy'=>'prodcat','hide_empty'=>0,'depth'=>0,'hierarchical'=>true,'child_of'=>$header_term->term_id );
    	} else {
    		$header_args = array ('taxonomy'=>'prodcat','hide_empty'=>0,'depth'=>0,'hierarchical'=>true,'child_of'=>$header_term->parent );
    	}
    } else {
    	$header_args = array ('taxonomy'=>'prodcat','hide_empty'=>0,'depth'=>0,'hierarchical'=>true);
    }

    and then...

    $roots_terms = apply_filters( 'taxonomy-images-get-terms', '' , array( 'taxonomy' => 'prodcat', 'term_args' => $header_args )  );
    
    if ( ! empty( $roots_terms ) ) {
    	$roots_head_img = '';
    	foreach( (array) $roots_terms as $roots_term ) {
    		$roots_head_img .= wp_get_attachment_image( $roots_term->image_id, 'full' ) ;
    		$roots_head_img .= '<h4><a>taxonomy ) ) . '">' . $roots_term->name . '</a></h4>';
    		$roots_head_img .= '<p>' . $roots_term->description . '</p>';
    	}
    }

    But I'm just getting all the images all the time, not just the children of the current taxonomy.

    What did I do wrong? ;)

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

  2. elbego
    Member
    Posted 1 year ago #

    Sorted - used:

    'parent' => $current_term->term_id,

    instead of:

    child_of => $current_term->term_id,

  3. sablednah
    Member
    Posted 1 year ago #

    Thanks that got me in the right direction ;)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic