WordPress按category_name获取帖子不起作用

时间:2019-04-11 14:40:50

标签: php wordpress loops

我需要按类别列出帖子顺序。我的显示出现问题按类别的帖子没有人为我工作,例如“ Category_name,tag_id,cat等。”

Event "quoteadded" is emitted in component <AppNewQuote> but the handler is registered 
for "quoteAdded". Note that HTML attributes are case-insensitive and you cannot use v- 
on to listen to camelCase events when using in-DOM templates. You should probably use 
"quote-added" instead of "quoteAdded".

1 个答案:

答案 0 :(得分:0)

您使用的是自定义帖子类型,这意味着它不会包含常规类别,而是具有分类法(用作类别),这意味着您需要使用税收查询,并且还需要检查条款,未经测试,但可以正常工作:

$taxonomy = 'portfolio_cat';
$cats = get_terms($taxonomy);

foreach ($cats as $cat) {
  $args1 = array(
    'post_type' => 'advanced_portfolio',
    'posts_per_page' => -1,
    'tax_query' => array(
      array(
        'taxonomy' => 'portfolio_cat',
        'field'    => 'slug',
        'terms'    => 'video'
      ),
    ),
  );

  query_posts($args1);

  if (have_posts()) : 
    while (have_posts()) : the_post(); 
      the_title();
    endwhile;
  endif;
}
wp_reset_query();