Output slugs to use as class names for every taxonomy a post is attached to

I’d recommend using get_the_terms instead of get_terms. It specifically pulls out the terms that are attached to a given post. If you use it within the loop, it’ll only give you the terms that are attached to that post.

It’d look something like this:

$query = new WP_Query( $args ); if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();

$slugs = array();    
$directory_terms = get_the_terms( $post->ID, 'directory_tag');

foreach ( $directory_terms as $term ) {
    $slugs[] = $term->slug;
}

$class_names = join( ' ', $slugs ); 

?> 

<div class="' . <?php if ( isset( $class_names) ) { echo ' ' . $class_names;} ?> . '"> 

You could obviously refine your search further if you only need specific terms from that taxonomy. get_the_terms returns a list of WP_Term objects that you can narrow down in any way you see fit.

EDIT: Updated code to show how to implement in a div.

EDIT: Added missing semi-colon.