Skip to content

Instantly share code, notes, and snippets.

@reediredale
Created June 28, 2012 02:26
Show Gist options
  • Save reediredale/3008371 to your computer and use it in GitHub Desktop.
Save reediredale/3008371 to your computer and use it in GitHub Desktop.
Custom Post Type Loop
<ul class="filterable-grid clearfix">
<?php $wpbp = new WP_Query(array( 'post_type' => 'portfolio', 'posts_per_page' =>'-1' ) ); ?>
<?php if ($wpbp->have_posts()) : while ($wpbp->have_posts()) : $wpbp->the_post(); ?>
<?php $terms = get_the_terms( get_the_ID(), 'filter' ); ?>
<li data-id="id-<?php echo $count; ?>" data-type="<?php foreach ($terms as $term) { echo strtolower(preg_replace('/\s+/', '-', $term->name)). ' '; } ?>">
<?php if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) : ?>
<?php the_post_thumbnail('portfolio'); ?>
<?php endif; ?>
<p><a href="<?php the_permalink(); ?>"><?php echo get_the_title(); ?></a></p>
</li>
<?php $count++; ?>
<?php endwhile; endif; ?>
<?php wp_reset_query(); ?>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment