我有三个查询参数用于过滤网格中的帖子。按作者和状态运行良好,但ACF meta\\u查询不起作用。I选择设置字段:http://prntscr.com/pi6m66
我需要当选择“Ne”值时从网格隐藏帖子,但它仍然显示在那里。
function my_super_filer_function2($query_args){
global $post;
$post_author = $post->post_author;
$query_args[\'author\'] = $post_author;
$query_args[\'post_status\'] = array(\'publish\', \'future\');
$query_args [\'meta_query\']= array(
\'meta_key\' => \'zobrazitnatridy\',
\'meta_value\' => \'Ne\',
\'meta_compare\' => \'!=\'
);
return $query_args;
}
add_filter(\'my_super_filter2\', \'my_super_filer_function2\');
怎么了?
SO网友:Vantiya
您非常接近它,只需要稍微修改一下代码。看,我已经为你更新了代码。
function my_super_filer_function2($query_args){
global $post;
$post_author = $post->post_author;
$query_args[\'author\'] = $post_author;
$query_args[\'post_status\'] = array(\'publish\', \'future\');
$query_args[\'meta_query\'] = array(
array(
\'key\' => \'zobrazitnatridy\',
\'value\' => \'Ne\',
\'compare\' => \'!=\'
)
);
return $query_args;
}
add_filter(\'my_super_filter2\', \'my_super_filer_function2\');