2014-09-01 111 views
0

自定义帖子类型的分类查询不显示结果。定期查询自定义类型显示结果。我可以将自定义税赋分配给自定义类型。当我运行查询时,我什么也得不到,只是一个错误。我得到这个错误:wordpress - WP查询自定义类型/税不显示帖子

Notice: Undefined offset: 0 in /Applications/MAMP/htdocs/folsom/wp-includes/query.php on line 2526 

这里是我的查询:

 $args = array(
      'post_type' => 'product', 
      'tax_query' => array(
       array(
        'taxonomy' => 'product-cat', 
        'term' => 'featured', 
        'field' => 'slug' 
        ) 
      ) 
     ); 

**更新:命中进入我做了。我在添加更多信息的过程中

**更新:我确保将分类法添加到参数类型的参数中,定义了优先级,以便他们首先注册。

add_action('init', 'create_product_taxonomies', 0); 

add_action('init', 'setup_custom_post'); 
function setup_custom_post(){ 
$args = array(
    'label'     => 'products', 
    // Bunch of other stuff 
    'taxonomies'   => array('product-cat'), 
    ), 

); 

register_post_type('product', $args); 
} 
+1

你要添加其他内容? – 2014-09-01 02:40:59

回答

1

看起来像添加了错误的分类参数。使用'条款'而不是'条款'。所以,你的参数数组看起来象下面这样:

$args = array(
     'post_type' => 'product', 
     'tax_query' => array(
      array(
       'taxonomy' => 'product-cat', 
       'terms' => 'featured', 
       'field' => 'slug' 
       ) 
     ) 
    ); 

欲了解更多信息请访问http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters

+0

错别字。总是一个错字...:/ – Plummer 2014-09-01 12:44:28

相关问题