我通過第一個循環獲取category_name =「Products」的第一個列表。執行多重循環
而且the_content我得到這樣的:
例子:
一個
我已成立一個名爲$這裏給一個變量名
乙
Ç
d = get_the_content()/ * $ product_category =「A」*/
現在我想執行一個內部循環來獲取category_name =「$ product_category」的嵌套列表。
這裏是我當前的代碼:
<?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(); ?>
我的輸出只顯示第一個項目:
例子:
一個
如何使用多循環得到結果是:
例如:
一個
產品1
產品2
乙
- 產品3
Ç
- product4的
d
產品5
產品6
對不起,我在WordPress中仍然是新的
'$ PRODUCT_CATEGORY = get_the_content(); '將內容作爲分類名稱?這聽起來不對 –
@PushpakPatel我還是在這裏新的。這個變量賦值方法我在Wordpress論壇網站上提及。我可以知道如何將「the_content」分配給變量嗎? – user3663143