Support

Home Forums Event Espresso Premium Displaying Category(s)

Displaying Category(s)

Posted: February 10, 2017 at 9:08 am

Viewing 6 reply threads


David

February 10, 2017 at 9:08 am

Hello

I’m currently displaying the category the event is in, in the following format:

$category = espresso_event_categories($post->ID,'none', FALSE);

However occasionally an event is in two categories.

I’d prefer it for each category to be in array as I want to make the category clickable to go to the category page. Is this possible?

Thanks


Josh

  • Support Staff

February 10, 2017 at 9:17 am

Hi David,

That should already be happening because the helper method for espresso_event_categories loops through all of the event categories and displays a link for each one. You might be running into an issue with the second param set to none, it should actually be a boolean. So can you try:

$category = espresso_event_categories($post->ID, FALSE, FALSE);

instead?


David

February 10, 2017 at 10:06 am

Ah yes that does work thanks.
However,
Is there anyway of setting a class for the links that it generates, preferably different for each category?
The client wants to have the name of the category highlighted in a different colour, depending on what category the event is in.

David


Josh

  • Support Staff

February 10, 2017 at 11:51 am

Hi David,

Yes there are ways. You can add a custom helper function to a site specific plugin, like this example function:

https://gist.github.com/joshfeck/7c2229bb90cf850e35e3afd18ac3dcb9

Then you call your custom helper in your template:

$category = my_event_categories_with_classes($post->ID, FALSE);


David

February 10, 2017 at 2:05 pm

Thanks Josh

However I’m now getting this error:

Call to undefined method EED_Events_Archive::link_target()


David

February 10, 2017 at 2:12 pm

I’ve just taken that line out the code and it seems to have worked – I’m guessing it’s something to do with setting the target, which in this instance doesn’t need to be set.


Josh

  • Support Staff

February 10, 2017 at 2:49 pm

That’s a defined method. I wonder if your code is running too late, or possibly your page isn’t technically an event custom post type so the class might not be loaded on that page. In either case you don’t need it.

Viewing 6 reply threads

The support post ‘Displaying Category(s)’ 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