Support

Account

Home Forums General Issues Advance wp_query with conditions… Reply To: Advance wp_query with conditions…

  • banner_cats is a multiselect field. This field will contain an array of category IDs and will be stored as a serialized array. You can’t do "IN" or "=" here.

    To match this you need to do something like this:

    
    array(
        'key' => 'banner_cats',
        'value' => '"'.$cat_id.'"',
        'compare' => 'LIKE',
    )
    

    Notice the double quotes include in the value. This is so that 1 will only match 1 and not 10, 20.

    To do something resembling an “IN” you would need to loop through the list of categories and create a “LIKE” query for each of them.

    The reason that you get nothing is that the meta queries on banner_cats and banner_towns are retuning nothing.

    Hope that helps.

    ~JH