[英]Wordpress retrieve posts from custom Taxonomy
我正在嘗試從我創建的gallery_Category分類法中的5類帖子中加載所有圖像。 沒有任何工作,我看不出為什么不這樣做。
<?php
$args = array(
'post_type' => 'post',
'taxonomy' => 'gallery_category',
'term_id' => '5'
);
$query = new WP_Query($args);
while ($wp_query->have_posts()) {
$wp_query->the_post();
?>
<?php the_post_thumbnail(); ?>
<?php } ?>
<?php
$args = array(
'post_type' => 'post',
'tax_query' => array(
array(
'taxonomy' => 'gallery_category',
'field' => 'slug',
'terms' => '5'
)
)
);
$my_query = new WP_Query($args);
while ($my_query->have_posts()) {
$my_query->the_post();
if ( has_post_thumbnail()) {
the_post_thumbnail();
}
}
?>
嘗試這個
也請參考這里
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.