Support

Account

Home Forums General Issues Query Posts & Checkbox Custom Fields

Solved

Query Posts & Checkbox Custom Fields

  • You have a great guide here on filtering data based on Advanced Custom Fields in the database: http://www.advancedcustomfields.com/resources/how-to/how-to-query-posts-filtered-by-custom-field-values/

    But I ran into something a bit weird when trying to work through the examples.

    I have a checkbox custom field for different regions of the world. And I used the alternative syntax you offered up to have a different value and label. Like this: “china : China”.

    If I then try to follow the first example on the above page and pull posts out of the database based on a region and its value, it won’t work.

    	'meta_key' => 'region',
    	'meta_value' => 'china',

    Not happening.

    Looking in the database, that meta_key is actually saved differently.

    It looks like this:

    a:1:{i:0;s:5:"china";}

    If I then try to pull from the database using that meta_value, it works.

    Any thoughts?

  • I’m a fool. That’s why you’re allowed to scroll in these modern, new-fangled browsers.

    Sorry!

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

The topic ‘Query Posts & Checkbox Custom Fields’ is closed to new replies.