Support

Account

Home Forums General Issues How to return ACF Checkbox items with only one value in meta query?

Solved

How to return ACF Checkbox items with only one value in meta query?

  • So there are activities with more than one custom field checkbox value, but I need to only display the ones that has only a single value named type “Sports”. So that if a post has “Sports” and “Works” it isn’t considered in the query. I’m aware compare like doesn’t behave this way…

    starting code:

    $args = array (
                'meta_query'             => array(
                  'relation'    => 'AND',
                    array(
                      'key'   => 'type_activity',
                      'value'   => 'Sports',
                      'compare' => 'LIKE',
                      ),
                  ),               
                'meta_key'               => 'fecha_de_inicio',
                'orderby'                => 'meta_value',
                'order'
  • Not sure but something like this should work

    'meta_query'             => array(
                  'relation'    => 'AND',
                    array(
                      'key'   => 'type_activity',
                      'value'   => 'Sports',
                      'compare' => 'LIKE',
                      ),
                    array(
                      'key'   => 'type_activity',
                      'value'   => 'Works',
                      'compare' => 'NOT LIKE',
                      ),
                  ),
  • Thank you so much that did it!!! 🙂

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

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.