Below is the custom query am running on my wordpress site to get the results from postmeta table. When I var_dump
the results then I can see the values correctly but when am trying to access a single field from the array, it doesn't work.
Am I missing something?
<?php
$key = "sc_event_year";
$value = $today_year;
global $wpdb;
$query = new WP_Query( array( 'meta_key' => $key, 'meta_value' => $value ) );
//var_dump($query);
foreach($query as $result){
echo $result->post_id;
}
?>