I'm trying to build kind of a filtering system for the events displayed on my website. I've made a custom post type 'Event', with a 'City' field. On my 'calendar' template page, I'm gathering all the events like this :
$querystr = "
SELECT *
FROM $wpdb->posts wposts, $wpdb->postmeta metastart
WHERE wposts.ID = metastart.post_id
AND metastart.meta_key = '_cp_date'
AND wposts.post_type = 'Event'
AND wposts.post_status = 'publish'
AND metastart.meta_value >= DATE_FORMAT(CURRENT_DATE(), '%m/%d/%Y')
ORDER BY metastart.meta_value ASC
";
$events = $wpdb->get_results($querystr, OBJECT);
And then, the loop displaying them.
What I would like to do, is to have buttons that would, on click, run another SQL query with a match on the city, and then replace the content with the result of that new query. I'm wondering what would be the "best" way to achieve this. Wouldn't ajax be my solution ?
