WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 was marked as an exact duplicate of an existing question.

My question was fantastically answered on Wordpress Stack Exchange:


share|improve this answer

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