php - WordPress: Exclude posts with meta_query - Not every posts has the meta_field -
i want exclude every post specific value of custom meta field. problem is, not every posts has meta field.
my code looks (excerpt of working loop):
// wp_query arguments $args = array ( 'post_parent' => $parentid, 'orderby' => 'menu_order', 'order' => 'asc', 'post_type' => array( 'page' ), 'meta_query' => array( array( 'key' => 'hide', 'value' => 1, 'compare' => '!=' ) ) );
not every posts uses field "hide". posts giving null. think, loop isn't working because of that?!
is correct? necessary every posts has value key?
try check sql statement doing below snippet.
$customposts = new wp_query($yourargs); echo "last sql-query: {$customposts->request}";
Comments
Post a Comment