Skip to content

Instantly share code, notes, and snippets.

@sidharrell
Last active December 31, 2015 06:19
Show Gist options
  • Select an option

  • Save sidharrell/7946710 to your computer and use it in GitHub Desktop.

Select an option

Save sidharrell/7946710 to your computer and use it in GitHub Desktop.
count number of events in a category
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