Im using event calendar plugin where I can set event date for posts and it shows in calendar widget. Everything is working as inteded but I would also like to query post by event date.
Problem is event date is stored in separate table named
wp_ftcalendar_events. Name of meta key is
start_datetime. Table starts with post ID so it's shared for both tables. Unfortunately joining tables is beyond my knowledge.
My try doesn't work:
<?php global $wpdb; $date = date("Y-m-d"); $querystr = " SELECT $wpdb->posts.* FROM $wpdb->posts, $wpdb->wp_ftcalendar_events WHERE $wpdb->posts.post_parent = $wpdb->wp_ftcalendar_events.post_parent AND $wpdb->posts.post_status = 'publish' AND $wpdb->wp_ftcalendar_events.meta_key = 'start_datetime' AND $wpdb->wp_ftcalendar_events.meta_value > " . $date . " ORDER BY $wpdb->wp_ftcalendar_events.meta_value ASC "; $pageposts = $wpdb->get_results($querystr, OBJECT); foreach ($pageposts as $post): ?> <!-- do stuff --> <?php endforeach; ?>