Support » Fixing WordPress » WP_Query with meta_query

  • I’m trying to list post with different custom fields

    my args looks like this:

    $args = array(
     	                                'post_type' => 'post',
     	                                'meta_query' => array(
    		                                'relation' => 'AND',
     			                                'key' => 'ACF_type',
    			                                 'value' => $t,
    			                                 'compare' => 'LIKE'
     			                                'key' => 'ACF_sex',
     			                                'value' => $s,
     			                                'compare' => 'LIKE'

    And that works but I realy whant to use ‘compare’ => ‘=’ but when change to this no post are listed
    I’ve tried with string,char and numeric but nothing shows when I use ‘=’

    What am I doing wrong?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator keesiemeijer


    That’s strange. And when you remove ‘compare’ from the array? The default value is ‘=’, so you don’t really need it. Try also with this 'relation' => 'OR'

    Yes I think it’s strange
    I’ve tried to use OR and then I get more hits but I whant to use AND to only show post with the both values

    I’m using Advanced Custom Fields plugin to add this different custom fields but that schould not be the problem because I can use the custom fields like normal fields

    Moderator keesiemeijer


    – deactivating all plugins to see if this resolves the problem? If this works, re-activate the plugins one by one until you find the problematic plugin(s).

    – switching to the default theme to rule out any theme-specific problems.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WP_Query with meta_query’ is closed to new replies.