Support

Home Forums Event Espresso Premium Display category tag in upcoming events widgets

Display category tag in upcoming events widgets

Posted: September 13, 2021 at 3:58 pm


Mullibeer

September 13, 2021 at 3:58 pm

Hello,

I’m wondering if there is a way to display the category tag in the upcoming events widget? I’m using this widget on the front page of a website, and it is displaying the upcoming events just right, with date and title, but visitors can’t see the category of the event, which is a bit confusing. Hope to hear.


Tony

  • Support Staff

September 16, 2021 at 4:34 am

Hi there,

We don’t have an option to do display the category although if you are comfortable with PHP you could add it into the widget.

Are you displaying a single category with the widget or all?

I’m assuming all and you want each individual event to display the category?


Mullibeer

September 22, 2021 at 11:39 am

Iā€™m assuming all and you want each individual event to display the category?

Yes this is exactly what I need, do you have an code example perhaps that I can copy/paste? I’m not a programmer unfortunately, but I can read and edit.


Tony

  • Support Staff

September 22, 2021 at 2:30 pm

This snippet allows you to create a copy of the widget:

https://gist.github.com/Pebblo/d0d5f485ae0599e56e20

Click download zip on the top right of that page, then upload the zip to your set in Dashboard -> Plugins -> Upload plugin.

Activate it and you’ll have ‘Custom Event Espresso Upcoming Events’ widget, it’s a copy of the original so use it in place of the original widget.

Then in that custom widget file you can use something like:

$category = $event->first_event_category();
if ($category instanceof EE_Term) {
    echo '<span>Category: ' . $category->name() . '</span>;
}

Where you add that depends on how you want it to output, but for example between the current 380 and 381 lines.


Mullibeer

September 23, 2021 at 12:24 pm

Working, thank you very much! šŸ™‚


Tony

  • Support Staff

September 23, 2021 at 12:38 pm

You’re most welcome šŸ™‚

The support post ‘Display category tag in upcoming events widgets’ 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