Home › Forums › General Issues › Query Multiple Conditions › Reply To: Query Multiple Conditions
Awesome, thanks John! That worked. (Though a comma was needed after the ‘key’ line)
The Toggle was actually a radio button with “Yes” and “No”, but I get it with true/false. The final query arg ended up being:
function bem_query_only_published_posts( $args, $field, $post_id ) {
$args['post_status'] = array( 'publish' );
$args['meta_query'] = array(
array(
'key' => 'acf_toggle_field_123',
'value' => 'Yes'
)
);
return $args;
}
add_filter( 'acf/fields/post_object/query', 'bem_query_only_published_posts', 10, 3 );
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.