[英]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.