Title: How to execute Multiple Loop
Last modified: August 21, 2016

---

# How to execute Multiple Loop

 *  [William1234](https://wordpress.org/support/users/william1234/)
 * (@william1234)
 * [11 years, 12 months ago](https://wordpress.org/support/topic/how-to-execute-multiple-loop/)
 * I go through first loop to get the first list where the category_name=”Products”.
   
   And the_content I get like this: Example: A B C D
 * I had set a variable name called $product_name = get_the_content() /*$product_category
   =”A” */
    Now I wanna execute a inner loop to get the nested list where the category_name
   =”$product_category”. Here is my current code:
 *     ```
       <?php query_posts('category_name=Products'); ?>
       				<?php while (have_posts()) : the_post(); ?>
                                       <li>
       					<a>
       					<div style="padding:5px;background-color:black;margin-bottom:2px;">
       					<div style="display:inline-block;width:100px;vertical-align:middle;">
       					<?php if ( has_post_thumbnail() ) { ?>
         					<?php the_post_thumbnail(); ?>
       					<?php } ?>
       					</div>
       					<div style="display:inline-block;height:100%;">
       						<a><?php the_title(); ?></a>
       					</div>
       					</div>
       					</a>
   
       					<?php $product_category = get_the_content(); ?>
       					<ul>
       					<?php query_posts('category_name=$product_category'); ?>
       					<?php while (have_posts()) : the_post(); ?>
                                       	<li>
       						<a><?php the_title(); ?></a>
       					</li>
       					<?php endwhile; ?>
       					</ul>
   
       				</li>
             				<?php endwhile; ?>
       				<?wp_reset_query(); ?>
       ```
   
 * My output just show the first item:
    Example: A
 * How can I use the multi loop to get the result like:
    Example: A – product1 –
   product2 B – product3 C – product4 D – product5 – product6
 * Sorry that I still new in WordPress

Viewing 1 replies (of 1 total)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [11 years, 12 months ago](https://wordpress.org/support/topic/how-to-execute-multiple-loop/#post-5026573)
 * Have you tried reviewing [multiple Loops](http://codex.wordpress.org/The_Loop#Multiple_Loops)?

Viewing 1 replies (of 1 total)

The topic ‘How to execute Multiple Loop’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [esmi](https://wordpress.org/support/users/esmi/)
 * Last activity: [11 years, 12 months ago](https://wordpress.org/support/topic/how-to-execute-multiple-loop/#post-5026573)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
