Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple wordpress loops for custom post type & taxonomy with no duplicates
    primarykey
    data
    text
    <p>I'm trying to make a custom template to display multiple loops from the same custom post type, but different categories.</p> <p>Here's what I am after:</p> <p><strong>From custom post type: 'Portfolio'</strong></p> <p><strong>In custom category 1 'Music':</strong></p> <ul> <li>1 featured post at top</li> <li>Music Heading</li> <li>3 sub-featured posts</li> <li>12 posts (title only)</li> </ul> <p><strong>In custom category 2 'Presenters':</strong> - Presenters Heading - 3 posts</p> <p><strong>In custom category 3 'News':</strong> - News Heading - 3 posts</p> <p>Here's the code I am working with:</p> <pre><code> &lt;?php if (have_posts()) : while (have_posts()) : the_post(); //WP loop ?&gt; &lt;?php the_content(); ?&gt; &lt;?php $args=array( //Loop 1 'post_type' =&gt; 'dt_portfolio', 'taxonomy' =&gt; 'dt_portfolio_category', 'term' =&gt; 'music', 'posts_per_page' =&gt; 16 ); $myloop = new WP_Query($args); if($myloop-&gt;have_posts()) : while($myloop-&gt;have_posts()) : $myloop-&gt;the_post(); ?&gt; &lt;!--the content --&gt; &lt;?php endwhile; endif; ?&gt; &lt;?php wp_reset_query(); // end music loop ?&gt; </code></pre> <pre><code> &lt;h2&gt;Presenters&lt;/h2&gt; &lt;?php $args=array( //Loop 2 'post_type' =&gt; 'dt_portfolio', 'taxonomy' =&gt; 'dt_portfolio_category', 'term' =&gt; 'presenters', 'posts_per_page' =&gt; 3 ); $myloop = new WP_Query($args); if($myloop-&gt;have_posts()) : while($myloop-&gt;have_posts()) : $myloop-&gt;the_post(); ?&gt; &lt;!--the content --&gt; &lt;?php endwhile; endif; ?&gt; &lt;?php wp_reset_query(); // end presenters loop ?&gt; </code></pre> <pre><code> &lt;h2&gt;News&lt;/h2&gt; &lt;?php $args=array( //Loop 3 'post_type' =&gt; 'dt_portfolio', 'taxonomy' =&gt; 'dt_portfolio_category', 'term' =&gt; 'news', 'posts_per_page' =&gt; 3 ); $myloop = new WP_Query($args); if($myloop-&gt;have_posts()) : while($myloop-&gt;have_posts()) : $myloop-&gt;the_post(); ?&gt; &lt;!--the content --&gt; &lt;?php endwhile; endif; ?&gt; &lt;?php wp_reset_query(); // end news loop ?&gt; &lt;?php endwhile; endif; // end WP loop?&gt; </code></pre> <p>Overall the 3 loops work great.</p> <p>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. </p> <p>Thank You!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload