Support

Home Forums Event Espresso Premium Event category

Event category

Posted: July 30, 2014 at 9:47 am

Viewing 4 reply threads


Joe Czucha

July 30, 2014 at 9:47 am

Hi guys,

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.

Is this possible? Thanks


Joe Czucha

July 30, 2014 at 9:48 am

Forgot to mention that I’m using EE3…


Josh

  • Support Staff

July 30, 2014 at 1:30 pm

Hi Joe,

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:

$category_name = espresso_event_category_data($event_id, TRUE);
$category_css = sanitize_title_with_dashes($category_name);


Joe Czucha

August 2, 2014 at 7:01 pm

Thanks Josh, that worked a treat.

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…

Thanks 🙂


Dean

August 4, 2014 at 4:23 am

Hi Joe,

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.

Event Espresso