Last active
December 31, 2015 06:19
-
-
Save sidharrell/7946710 to your computer and use it in GitHub Desktop.
count number of events in a category
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function espresso_count_the_events_in_a_category ($atts) { | |
| extract(shortcode_atts(array('event_category_id' => FALSE), $atts)); | |
| if (!$event_category_id) return FALSE; | |
| global $wpdb; | |
| return $wpdb->get_var($wpdb->prepare("SELECT COUNT(ed.id) FROM " . EVENTS_DETAIL_TABLE . " ed JOIN " . EVENTS_CATEGORY_REL_TABLE . " cr ON ed.id = cr.event_id JOIN " . EVENTS_CATEGORY_TABLE . " cd ON cr.cat_id = cd.id WHERE cd.category_identifier = '%s' AND ed.event_status != 'D'", $event_category_id)); | |
| } | |
| add_shortcode('COUNT_EVENTS_IN_CATEGORY', 'espresso_count_the_events_in_a_category'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment