Order posts with a custom field but also without

I am querying and ordering posts with this code but my theme adds the custom field (cb_vote_nb_vote) only if someone clicks the “vote” button, since I am doing a listing, posts created without that custom field under a specific category must also be displayed. How do I achieve that?

global $wp_query;
$paged = $wp_query->get('paged') ? : 1;
$posts_per_page = 10; // feel free to change this
$args = array(
'cat'            => 47,
'meta_key'       => 'cb_vote_nb_vote',
'orderby'        => 'meta_value',
'order'          => 'DESC',
'paged'          => $paged,
'posts_per_page' => $posts_per_page
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();

$current_order = ( $query->current_post + 1 ) + ( $posts_per_page * ( $paged - 1) );
echo 'Current post order is :' . $current_order;

endwhile; endif;
wp_reset_postdata();

Related posts