Skip to content

Instantly share code, notes, and snippets.

@dibakarjana
Last active March 6, 2018 14:51
Show Gist options
  • Save dibakarjana/6c847753115be72f6c2dd6f813bebb06 to your computer and use it in GitHub Desktop.
Save dibakarjana/6c847753115be72f6c2dd6f813bebb06 to your computer and use it in GitHub Desktop.
Custom post type loop and taxonomy term as class
<?php
$new = new WP_Query('post_type=property');
while ($new->have_posts()) : $new->the_post(); ?>
<?php $terms = get_the_terms( $post->ID, 'location' ); ?>
<div class="element-item transition <?php foreach( $terms as $term ) echo ' ' . $term->slug; ?>" data-category="transition">
<div class="name"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
</div>
<?php endwhile; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment