繁体   English   中英

使用自定义分类名称显示帖子-Wordpress

[英]Showing posts using custom taxonomy name - wordpress

我有以下代码行:

$args = array( 'category_name' => the_slug(), 'post_type' => 'Feature', 'posts_per_page' => 2, 'orderby'=> rand );

只要类别名称与当前页面的条目相同,该方法就可以很好地显示类别中的两个帖子。 我需要将类别名称更改为我的自定义分类法,这称为“特征化”。 我试过将category_name更改为featureing_name,但它只显示了所有帖子,而不是仅显示该分类中的帖子。

最终得到以下结果:

$args = array(
'showposts' => -0,
'post_type' => 'feature',
'orderby' => rand,
'tax_query' => array(
   array(
    'taxonomy' => 'featuring',
    'field' => 'slug',
    'terms' => the_slug()
    )
  )
);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM