0

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.com/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?

0

1 Answer 1

0

You'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');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.