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
DI 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:
AHow can I use the multi loop to get the result like:
Example:
A
– product1
– product2
B
– product3
C
– product4
D
– product5
– product6Sorry that I still new in WordPress
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘How to execute Multiple Loop’ is closed to new replies.