I have a custom query and I am filtering out events by custom field: event-month. I simple filter our the events that dont have a month_number = to date(“n”);
Its a pretty great little query, but I need to orderby another custom field, event_date.
Do I need a custom function or something to get this done. I simply want to orderby => event_date
but I am currently using event-month for my query.
<?php
$event_query = new WP_Query(
array(
'post_type' => 'event', // only query events
'meta_key' => 'event-month', // load up the event_date meta
'order_by' => '',
'order' => 'asc', // ascending, so earlier events first
'meta_query' => array(
array( // restrict posts based on meta values
'key' => 'event-month', // which meta to query
'value' => date("n"), // value for comparison
'compare' => '=', // method of comparison
'type' => 'NUMERIC' // datatype, we don't want to compare the string values
) // meta_query is an array of query ites
) // end meta_query array
) // end array
); // close WP_Query constructor call
?>