I need to build a custom table of events which includes extra meta fields. I want to include the event categories as CSS classes on the table. I am customising espresso_table.php. Can I get a hint on what SQL query I need to run to pull out these classes? [EVENT_ESPRESSO_CATEGORY] shortcode seems to have all the categories included but I’m getting lost trying to follow the source for that function. Thanks in advance!
Thanks as always Chris, didn’t see your reply till now. Yes I want to print the category name/id ( category_identifier field from the database) on each event – I need to color-code the table according to category, and want to use a CSS class like with WP post categories in the Loop.
It’s supposed to do that anyway, but for some reason the $category_identifier variable isn’t being passed to the event list template. This fills the variable so it will add it automatically to the div container, just add this somewhere in your event_list_display.php (like under all the status variables):
$category_identifier = $wpdb->get_var( "SELECT c.category_identifier FROM ". EVENTS_DETAIL_TABLE ." e JOIN " . EVENTS_CATEGORY_REL_TABLE . " r ON r.event_id = e.id JOIN " . EVENTS_CATEGORY_TABLE . " c ON c.id = r.cat_id WHERE e.id = ".$event_id );
In case anyone was curious the exact code I used was:
$CSSclass = $wpdb->get_var( "SELECT GROUP_CONCAT(c.category_identifier SEPARATOR ' cat-') as cssclass
FROM ". EVENTS_DETAIL_TABLE ." e
JOIN " . EVENTS_CATEGORY_REL_TABLE . " r ON r.event_id = e.id
JOIN " . EVENTS_CATEGORY_TABLE . " c ON c.id = r.cat_id
WHERE e.id = ".$event->id );
So as to get all category identifiers attached to an event.
Viewing 4 reply threads
The support post ‘Custom Espresso Table with Categories’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.
Support forum for the Custom Files add-on for EE3.