我取决于您是否正在查找空值:
$args = array(
\'post_type\' => LANDING__CUSTOM_POST,
\'meta_query\' => array(
array(
\'key\' => \'landing_exported\',
\'value\' => \'\',
\'compare\' => \'=\'
)
)
);
// query
$the_query = new WP_Query( $args );
搜索值,如:
meta_value = \'\'
或者如果你正在寻找NULL
更难的值(或者我找不到更简单的解决方案):
add_filter( \'posts_where\', \'my_modify_the_posts_where\' );
function lets_modify_the_posts_where( $clause = \'\' ) {
global $wpdb;
$clause .= " AND " . $wpdb->prefix . "postmeta.meta_value IS NULL"
return $clause;
}
$args = array(
\'post_type\' => LANDING__CUSTOM_POST,
\'meta_query\' => array(
array(
\'key\' => \'landing_exported\',
\'compare\' => \'EXISTS\'
)
)
);
// query
$the_query = new WP_Query( $args );
remove_filter(\'posts_where\', \'my_modify_the_posts_where\');
搜索值,如:
meta_value IS NULL