Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple loop issue - pull 1 featured and continue the loop without it
    primarykey
    data
    text
    <p>I am writing a custom multiple loop to be used on a custom category template page. The loop should put one post that is checked as featured in admin, in a separate div, and continue the loop displaying all posts from the category except the featured. </p> <p>Similar to the example provided on the <a href="http://codex.wordpress.org/The_Loop#Multiple_Loops_in_Action" rel="nofollow">codex page</a> except I don't want to create a separate category for the featured post.</p> <p>I am using <a href="http://www.advancedcustomfields.com/resources/field-types/checkbox/" rel="nofollow">Advanced Custom Fields</a> plugin for the check box that sets posts as featured.</p> <p>I have the following issue with my code: <code>if ($post-&gt;ID == $do_not_duplicate) continue;</code> prevents rest of the loop to be executed. The code below just pulls the latest featured post.</p> <p>Here is my function:</p> <pre><code>function featured() { $featured = new WP_Query(array( 'meta_query' =&gt; array( array( 'key' =&gt; 'featured', 'value' =&gt; '"top"', 'compare' =&gt; 'LIKE' ) ), 'posts_per_page' =&gt; 1 )); while ( $featured-&gt;have_posts() ) : $featured -&gt; the_post(); $do_not_duplicate = $post-&gt;ID; ?&gt; &lt;div id="featured"&gt; //featured post &lt;/div&gt;&lt;!-- end #featured --&gt; &lt;?php endwhile; if(have_posts()) : while (have_posts()) : the_post(); if ($post-&gt;ID == $do_not_duplicate) continue; ?&gt; &lt;div class="container"&gt; // normal posts &lt;/div&gt;&lt;!-- .charities-container --&gt; &lt;?php endwhile; endif; } </code></pre> <p>Your fresh eyes will help a lot!</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    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.
    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