Query posts with a certain meta key
-
Hello,
I have a custom field called “end-date”, and i need to query posts that have not passsed the date i declared to that value.
for example, i have a post that the meta key end-date is 110302 (year/month/day) and i dont want it in my query because its older than today’s date, but i want the ones that have a value that is still to come, like 110315
im defining a new query
$time = time() + ( get_option( 'gmt_offset' ) * 3600 ); $today = gmdate( 'ymd', $time ); $wp_query = new WP_Query( array( 'meta_key' => 'data-final', 'meta_value' => '$today', 'meta_compare' => '>=' ) );
i dont know if its correct, but i want to compare today’s date, to the date i have in the custom field.
Basicly what i need is, query every post that has a date that is newer than today, ommiting the ones that are older, order those results by another date in another custom field called date.
Its kind of complex, i hope someone cal help, Thank you
- The topic ‘Query posts with a certain meta key’ is closed to new replies.