term_id; $current_term = get_term($term_id); ?> 'attachment', 'post_mime_type' =>'image', 'post_status' => 'inherit', 'posts_per_page' => -1, 'tax_query' => array( array( 'taxonomy' => 'attachment_keyword', 'field' => 'slug', 'terms' => $current_term->slug, ), ), ); $query_images = new WP_Query( $query_images_args ); while ( $query_images->have_posts() ) : $query_images->the_post(); $ids_array[] = $post->ID; endwhile; $ids = implode(',', $ids_array); ?>