Custom Fields in get_posts

How do I query posts using get_posts and custompress custom fields? For example including this in my get_posts arguments...

'meta_query' => array(
	'key' => '_ct_checkbox_4fa95ad122cd6',
	'value' => 'Yes'
) not working for me. It just shows all posts regardless of value.

  • Arnold

    A custom checkbox is not a yes/no type item. A given checkbox field could be a collection of options each with their own checkbox per option. What is stored is the option name of the checkbox checked, or if unchecked, nothing. So if there were only 1 checkbox which is what you seem to be trying, the option name would either exist or not exist.

    So if your checkbox was1 option, call it 'Flag' you'd want something like.

    'meta_query' => array(
      'key' => '_ct_checkbox_4fa95ad122cd6',
      'value' =>  'Flag',
      'compare' => 'IN'

    Haven't actual tried it but that's close

  • aecnu

    Greetings pollenbrands,

    It appears this particular topic is now resolved/closed, if you need any further assistance please let us know.

    If it wasn't resolved, or you have any more questions related to this thread, please feel free to post them below including any new symptoms or errors and tick the 'Mark as Not Resolved (re-open)' box below the post area (or else we'll miss it!)

    Thank you for being a WPMU Dev member!

    Cheers, Joe :slight_smile:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.