【问题标题】:Showing posts using custom taxonomy name - wordpress使用自定义分类名称显示帖子 - wordpress
【发布时间】:2014-05-16 14:27:05
【问题描述】:

我有以下代码行:

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

只要类别名称与当前页面的 slug 相同,这在显示该类别中的两个帖子时效果很好。我需要将类别名称更改为我的自定义分类法,这称为“特征”。我尝试将 category_name 更改为 features_name,但它只显示了所有帖子,而不仅仅是来自该分类的帖子。

【问题讨论】:

    标签: php wordpress categories taxonomy


    【解决方案1】:

    得到以下结果:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-08
      • 2016-07-16
      • 2016-12-29
      • 1970-01-01
      相关资源
      最近更新 更多