我已经创建了一个自定义帖子类型。我能够添加所有的细节,它正在发挥作用。我有一个下拉列表,我正在该下拉列表中获取我的类别。一旦用户从下拉列表中选择了类别,则数据将相应显示。
我尝试了下面的代码,但没有得到任何结果。甚至错误也没有显示出来。
function eventsView( $atts ){
if($atts[\'cat\']==\'All\'){
$upcomingevents = get_posts(array(
\'showposts\' => 80, //add -1 if you want to show all posts
\'post_type\' => \'events\'
));
}else{
$upcomingevents = get_posts(array(
\'showposts\' => 10, //add -1 if you want to show all posts
\'post_type\' => \'events\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'events_cat\',
\'field\' => \'slug\',
\'terms\' => $atts[\'cat\'] //pass your term name here
)
))
);
}
echo"<pre>";
print_r($upcomingevents); // Nothing is showing int his variable.
// some more code here like foreach conditon
}