Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Possible Duplicate:
WP_Query with checkbox meta_query

Ok, so I have a custom post type and have used the Verve Meta Boxes plugin to create some custom meta values for the post type.

The meta box is called 'Subjects' and has a checkbox list of subjects to assign values to it. For example, I have ticked Math, English and Science.

Now I want to perform a WP_Query which will take an array of subjects selected by the user as an array, compare those subjects to those selected for the custom post type, and return posts if any of them match.

Here's the code so far:

$subjects_array = explode("_", $_GET["subjects"]);

$args = array(
            'post_status' => 'publish',
            'post_type' => 'any',
            'meta_query' => array(

         // Not sure what type of meta query to do   

            )
        );


$query = new WP_Query($args);

To cut a long story short, I just need to know if there's a way to perform a meta_query which will compare an array against whatever format the data in the meta box is in?

If this is not possible, I just need to know then I'll look at a different way of doing it, but I'm thinking there's perhaps some meta_query ability I don't know about.

Any help would be much appreciated.

share|improve this question

migrated from stackoverflow.com Jul 5 '11 at 13:01

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Rarst Jul 5 '11 at 14:13

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

add comment

1 Answer 1

My question was fantastically answered on Wordpress Stack Exchange:

http://wordpress.stackexchange.com/questions/21952/wp-query-with-checkbox-meta-query

share|improve this answer
add comment

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