I’m editing the event_list_display.php file (copied to my uploads folder) in order to customise the homepage layout. For each event, I want to output the category_id. I know I can use:
<?php echo do_shortcode('[CATEGORY_NAME event_id="'.$event_id.'"]');?> to output the category name, but I want the category_id so that I can use it as a class to add an icon to each event.
I’d recommend using a function instead of a shortcode to get the category name.
Along with that, you can take the category name and convert it to a CSS-ready class name using the WP sanitize_title_with_dashes() function. So you could set a few variables like this:
Is it also possible to somehow get a list of all the categories that exist in the system? I’m implementing a category filter so need to output a list of the available categories…
There isn’t a function that I can find that will get all the categories, so you may need to do an SQL query to get the details from the *_events_category_detail (* = your database prefix).
There is this function that will get the categories associated with one event espresso_event_category_data($event_id, $all_cats = FALSE) (this is found in /wp-content/plugins/event-espresso/includes/functions/main.php )
Viewing 4 reply threads
The support post ‘Event category’ 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 Event Espresso 3 and Event Espresso 4.