<!-- Begin custom tax loop -->
<?php
//Retrieve custom taxonomy terms using get_terms and the custom post type.
$categories = get_terms('tn_cstm_work_taxonomy','orderby=name');
//Iterate through each term
foreach ( $categories as $category ) :
?>
<div class="row">
//Use $category->slug to retrieve the slug
<section id="<?php echo $category->slug; ?>" class="large-12 columns" data-magellan-destination='<?php echo $category->slug; ?>'>
<h3><?php echo $category->name; ?></h3>
<ul class="large-block-grid-4 small-block-grid-2">
<?php
//Setup the query to retrieve the posts that exist under each term
$posts = get_posts(array(
'post_type' => 'tn_cstm_portfolio',
'orderby' => 'menu_order',
'order' => 'ASC',
'taxonomy' => $category->taxonomy,
'term' => $category->slug,
'nopaging' => true,
));
// Here's the second, nested foreach loop that cycles through the posts associated with this category
foreach($posts as $post) :
setup_postdata($post); ////set up post data for use in the loop (enables the_title(), etc without specifying a post ID--as referenced in the stackoverflow link above)
?>
<li>
<?php
//retrieves the post thumbnail for each post
$thumb = get_post_thumbnail_id();
$img_url = wp_get_attachment_url( $thumb,'medium' ); //get full URL to image (use "large" or "medium" if the images too big)
$image = aq_resize( $img_url, 300, 270, true ); //resize & crop the image using aqua resizer https://github.com/sy4mil/Aqua-Resizer
?>
<figure class="work-thumb">
<a class="th" href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>">
<?php if($image) : ?>
<img src="<?php echo $image ?>" alt="<?php the_title(); ?> thumb"/>
<?php else : ?>
<img class="" src="<?php bloginfo('stylesheet_directory'); ?>/img/small-placeholder.png" alt="placeholder image">
<?php endif; ?>
</a>
<figcaption><h4><a href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h4></figcaption>
</figure>
<?php }
?>
</li>
<?php endforeach; ?>
</ul>
</section>
</div><!-- .row -->
<?php endforeach; ?>//Easy Peasy
|