You can do that by using a query to get the post IDs of all posts that have the custom field and then excluding them from the main query:
$ids = $wpdb->get_col("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'destaque' ");
query_posts( array( 'cat' => '', 'posts_per_page' =>2, 'paged' => get_query_var('paged'),'post__not_in' => $ids ) );
Thread Starter
PIW
(@dbaldan)
Works like a charm!
I was trying to use this, but without success:
$args = array(
'cat' => '',
'posts_per_page' =>2,
'paged' => get_query_var('paged'),
'meta_query' => array(
array(
'key' => 'destaque',
'value' => '',
'compare' => 'LIKE'
)
)
);
$query = new WP_Query( $args );
God bless you 🙂