Note that there are some explanatory texts on larger screens.

plurals
  1. POWordpress displaying posts on different pages
    text
    copied!<p>I am creating a landing page (one page with many section) in WordPress, and I'm calling each section using get_template_part(). So I have something like this;</p> <pre><code> &lt;?php get_template_part( 'content', 'reasons-to-purchase'); ?&gt; &lt;?php get_template_part( 'content', 'testimonials'); ?&gt; &lt;?php get_template_part( 'content', 'reasons-to-purchase'); ?&gt; </code></pre> <p>Each content file then has a loop to return the posts that match its category, with posts_per_page set to one, as shown below (content-reasons-to-purchase.php);</p> <pre><code> &lt;?php $args = array( 'post_type' =&gt; 'section', 'category_name' =&gt; 'Reasons-To-Purchase', 'posts_per_page' =&gt; 1, 'orderby' =&gt; 'date', 'order' =&gt; 'DESC' ); $the_query = new WP_Query ( $args ); if (get_category_by_slug('Reasons-To-Purchase')-&gt;category_count &gt; 0 ) {?&gt; &lt;!-- Featured content image or slider. --&gt; &lt;div class="container panel"&gt; &lt;?php if ( have_posts() ) : while ( $the_query-&gt;have_posts () ) : $the_query-&gt;the_post(); ?&gt; &lt;?php the_content(); ?&gt; &lt;/div&gt; &lt;?php } ?&gt; &lt;?php wp_reset_query(); ?&gt; &lt;div class="clearfix"&gt;&lt;/div&gt; </code></pre> <p>What I would like to is create as many as these sections in which ever order I like and the loop within each section pulls the next post assigned to that category. So for example in the first 'reasons-to-purchase' section the first post is pulled and then in the second 'reasons-to-purchase' the second post is called. At the moment I reset the loop in each file using 'wp_reset_query()' so it doesn't interfere with the next section which may be different. Basically the loop has to continue for the next similar named section without duplicating any posts..</p> <p>Any ideas on how to do this or advice would be most appreciated.</p>
 

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