Working with a filter for a Wordpress query. If I use the $where line as shown below, the filter works.
Note in the query that I have a meta_key = mymeta_datetime and a meta_value of the actual datetime for the event.
When I comment out the $where line in the filter and try the line above that where meta_value > $today, this filter fails entirely, and no upcoming events are shown on the page.
How can I filter on mymeta_datetime to only show upcoming events?
// setup filter for where clause
function filter_where($where='') {
// filter for future events only
$today = date('Y-m-d H:i');
//$where .= " AND 'meta_value' > '$today'"; // this doesn't work :(
$where .= " AND post_date > '2013-02-15'"; // this works!
return $where;
}
add_filter('posts_where', 'filter_where');
$args = array('post_type' => 'gla_events', 'post_status' => 'publish', 'posts_per_page' => 100, 'caller_get_posts'=> 1, 'orderby'=>'meta_value', 'meta_key'=>'mymeta_datetime', 'order'=>'ASC');
$loop = new WP_QUERY($args);
remove_filter('posts_where', 'filter_where');
if($loop->have_posts()) {...}
Any help on this is appreciated. Thanks!