I'm trying to make a custom template to display multiple loops from the same custom post type, but different categories.
Here's what I am after:
From custom post type: 'Portfolio'
In custom category 1 'Music':
- 1 featured post at top
- Music Heading
- 3 sub-featured posts
- 12 posts (title only)
In custom category 2 'Presenters': - Presenters Heading - 3 posts
In custom category 3 'News': - News Heading - 3 posts
Here's the code I am working with:
<?php if (have_posts()) : while (have_posts()) : the_post(); //WP loop ?>
<?php the_content(); ?>
<?php $args=array( //Loop 1
'post_type' => 'dt_portfolio',
'taxonomy' => 'dt_portfolio_category',
'term' => 'music',
'posts_per_page' => 16
);
$myloop = new WP_Query($args);
if($myloop->have_posts()) : while($myloop->have_posts()) :
$myloop->the_post();
?>
<!--the content -->
<?php endwhile; endif; ?>
<?php wp_reset_query(); // end music loop ?>
<h2>Presenters</h2>
<?php $args=array( //Loop 2
'post_type' => 'dt_portfolio',
'taxonomy' => 'dt_portfolio_category',
'term' => 'presenters',
'posts_per_page' => 3
);
$myloop = new WP_Query($args);
if($myloop->have_posts()) : while($myloop->have_posts()) :
$myloop->the_post();
?>
<!--the content -->
<?php endwhile; endif; ?>
<?php wp_reset_query(); // end presenters loop ?>
<h2>News</h2>
<?php $args=array( //Loop 3
'post_type' => 'dt_portfolio',
'taxonomy' => 'dt_portfolio_category',
'term' => 'news',
'posts_per_page' => 3
);
$myloop = new WP_Query($args);
if($myloop->have_posts()) : while($myloop->have_posts()) :
$myloop->the_post();
?>
<!--the content -->
<?php endwhile; endif; ?>
<?php wp_reset_query(); // end news loop ?>
<?php endwhile; endif; // end WP loop?>
Overall the 3 loops work great.
The part I need help on is the 1st loop section. I need to take all 16 posts from the same custom taxonomy 'dt_portfolio_category' -> 'music'. But break them into a 1 top featured post (full-width), then a heading, then 3 sub-featured posts (3 columns), then 12 posts with just the title (3 columns). I have tried to break it into 3 separate loops, but the content gets duplicated... and I figure there must be a cleaner way to do it.
Thank You!