Created
June 3, 2021 13:08
-
-
Save ivo-ivanov/be9b7e0cc6f7f2dc9f785f6545480fbc to your computer and use it in GitHub Desktop.
Custom Meta Query in WP #wp #query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$args = array( | |
'post_type' => 'objekt', | |
'posts_per_page' => -1, | |
'no_found_rows' => true, | |
'suppress_filters' => false, | |
//Se the meta query | |
'meta_query' => array( | |
//comparison between the inner meta fields conditionals | |
'relation' => 'AND', | |
//meta field condition one | |
array( | |
'key' => 'stock', | |
'value' => 'Attika', | |
'compare' => '!=', | |
), | |
//meta field condition one | |
array( | |
'key' => 'lage', | |
'value' => 'Nassegasse 17', | |
//I think you really want != instead of NOT LIKE, fix me if I'm wrong | |
//'compare' => 'NOT LIKE', | |
'compare' => '=', | |
) | |
), | |
); | |
$the_query = new WP_Query($args); | |
while ( $the_query->have_posts() ) : $the_query->the_post(); | |
the_title(); | |
endwhile; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment