New WP Query Multiple Loops
-
I am trying to run multiple loops on a page template that pull a custom post type from categories and display the title, the content, and the custom metabox data that I created for the post. This is for a restaurant, and they will have a page (dinner menu) then I want to use multiple loops to pull categories for appetizers, soups, entrees, etc in order.
<main class="menu"> <div class="row"> <div class="span8 menu-entry dinner-menu"> <h1>Savannah's Dinner Menu</h1> <?php // Appetizers $the_query = new WP_Query( 'category_name=appetizer' ); // The Loop if ( $the_query->have_posts() ): while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <h2><?php the_title(); ?></h2> <p><?php the_content(); ?></p> <p class="price"> <?php post_meta($post->ID, 'price-box', true); ?></p> <?php endwhile; endif; wp_reset_postdata(); ?> <?php // Appetizers $query2 = new WP_Query( 'category_name=soups-and-salads' ); // The Loop if ( $query2->have_posts() ): while ( $query2->have_posts() ) : $query2->the_post(); ?> <h2><?php the_title(); ?></h2> <p><?php the_content(); ?></p> <p class="price"> <?php post_meta($post->ID, 'price-box', true); ?></p> <?php endwhile; endif; wp_reset_postdata(); ?> </div> </div> </main>
Currently this does not display any information in the <main> section, though there are no errors reported either. Not sure where I am going wrong.
Thanks for any help,
Bill
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘New WP Query Multiple Loops’ is closed to new replies.