You seem to be missing the meta_query
proprety and looking at your code you seem to have two meta values mixed, so we need to combine them.
$loop = new WP_Query([
'category_name' => 'gold',
'orderby' => 'rand',
'posts_per_page' => -1,
'meta_query' => [
'relation' => 'and',
[
'key' => 'status',
'value' => 'active'
],
[
'key' => 'end_date',
'value' => date('Y-m-d'),
'compare' => '>=',
'type' => 'DATE'
]
]
]);
Also date('y-m-d')
return the current date (if we go by the date this answer was creates it will return 21-10-14), that is not a valid date format you this compare will not work.
Even if it was are looking for posts that are equal or older then the current date, which, I assume is not correct (I cound be wrong so feel free to correct me on that =]).
You need to make sure that you have stored a valide date format in that meta field, needs to be date('Y-m-d')
instead of date('y-m-d')
, notice the upper case Y.