I have three query args for filtering posts in grid. By Author and Status works fine, but ACF meta_query not work. I setup field as select:
I need when is selected "Ne" value hide post from grid, but it still display there.
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');
What is wrong there?
I have three query args for filtering posts in grid. By Author and Status works fine, but ACF meta_query not work. I setup field as select: http://prntscr/pi6m66
I need when is selected "Ne" value hide post from grid, but it still display there.
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');
What is wrong there?
Share Improve this question edited Oct 12, 2019 at 1:39 heroj asked Oct 12, 2019 at 1:32 herojheroj 238 bronze badges 01 Answer
Reset to default 0You're very close to it just need to to modify your code little bit. See I've update code for you.
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');
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745087921a4610517.html
评论列表(0条)