From your comment:
it worked without the
array( 'key' => 'picture_url', 'value' =>
but I need to include it in the query…
'none', 'compare' => '!=' )
is it possible?
Yes, using named sub-meta queries like so:
$q_args = [
// ... other args here ...
'meta_query' => [
'picture_url' => [ 'key' => 'picture_url', 'value' => 'none', 'compare' => '!=' ],
'totalviews' => [ 'key' => 'totalviews', 'value' => '0', 'compare' => '>=', 'type' => 'NUMERIC' ],
],
'orderby' => 'totalviews', // set this to a key in the above meta queries
'order' => 'DESC',
];
The orderby
parameter can also be an array:
'orderby' => [
'totalviews' => 'DESC', // sort by meta_query key
'picture_url' => 'ASC', // sort by meta_query key
'date' => 'DESC', // sort by the post date
]
And (once again), orderby
is not a valid argument for an array in the meta_query
array. See here for more details.