我正在尝试显示具有自定义分类法的自定义帖子类型,但我没有任何运气。什么都没有出现。感谢您的帮助。
帖子类型 = 图库
自定义分类 slug = photoarea
我要显示的'photoarea' = fourth
<?php
$args = array(
'post_type' => 'gallery',
'tax_query' => array(
array(
'taxonomy' => 'photoarea',
'field' => 'fourth',
)
),
'posts_per_page' => 10,
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post();
the_post_thumbnail();
endwhile; endif;
wp_reset_query();
?>
最佳答案
您可以使用以下代码片段:
$the_query = new WP_Query( 'post_type=gallery&photoarea=fourth');
然后是你的 while 循环。
关于php - 自定义分类 WP_Query,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18283391/