Nesting WP loop [2 loops inside one]
-
Hi Guys,
I am trying to nest two loops in one loop.
The two loops below are pulling content from custom posts and working perfectly individually.
1st loop:
———————————————-<?php query_posts( array( 'post_type' => 'stories') ); while (have_posts()) : the_post();?><!-- begin of loop --> <section class="story-sec"> <h3><?php the_title() ?> <span><?php the_field('title_2nd_row'); ?></span></h3> <?php the_content() ?> </section> <?php endwhile; wp_reset_query(); ?><!-- end of loop -->
2nd loop:
———————————————–<?php query_posts( array( 'post_type' => 'products') ); while (have_posts()) : the_post();?><!-- begin of loop --> <div class="product" style="background: rgba(<?php the_field('box_color'); ?>)"> <h3><span><?php the_title(); ?></span><?php the_field('product_name_2nd_line'); ?></h3> <p><?php the_field('product_description'); ?></p> </div> <?php endwhile; wp_reset_query(); ?><!-- end of loop -->————————————————-
I want to add these two loop in one so the most latest post from any one of these custom post stays on TOP.
Does someone here knows how to do this? Thank you!!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Nesting WP loop [2 loops inside one]’ is closed to new replies.