WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

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

Here's are wp_query args:

$args = array(
    'post_type' => 'sportpages'
    ,'post_status' => 'publish'
    ,'posts_per_page' => 1000
    ,'post_parent' => 4738
    ,'meta_query' => array(
        'relation' => 'OR'
            'key' => 'ecpt_sportgender_2'
            ,'value' => 'Boys'
            ,'compare' => 'LIKE'
            'key' => 'ecpt_sportgender_2'
            ,'value' => 'Both'
            ,'compare' => 'LIKE'

My results are odd. I'm getting only the posts for Boys unless I swap Boys for Girls, in which case I get Girls. The only way to get "Both" is to make it get ONLY Both, and not do the relationship.

The order in which I put them in there makes no difference.

What am I missing?

share|improve this question

closed as too localized by Rarst Apr 24 '12 at 13:30

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

have you tried setting compare to =? – mor7ifer Apr 23 '12 at 20:46

You'll probably need to do one of the following

  • 'compare' => '=' (or leave it out, as it's the default)
  • or... 'value' => $wpdb->esc_like( '%Boys%' ) (needs global $wpdb;)
  • or... 'value' => $wpdb->esc_like( 'Boys' ) (needs global $wpdb;)
share|improve this answer
The compare = didn't work. Escaping the values gives the result of Both, but not Boys. – Topher Apr 23 '12 at 21:40
"the result of Both, but not Boys"...? So only Girls? Then It's not both... – kaiser Apr 23 '12 at 22:08
Also: Remove the 'post_parent' => 4738 – kaiser Apr 23 '12 at 22:09

I figured out my problem. The query WAS returning the proper results, but the results were getting munged in some later code. :(

Thanks for your time pondering this.

share|improve this answer

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