Support

Home Forums Event Espresso Premium Add category and tag to event pages

Add category and tag to event pages

Posted: July 20, 2021 at 7:47 pm


BCPTA

July 20, 2021 at 7:47 pm

Hello, I have searched these forums and can’t seem to find a conclusion on how to add the Event category and tags the events.

I figured out how to add the category description (without the category name), using this method: https://gist.github.com/joshfeck/2df649a11c8cda58e69d478a74873808

From this post: https://eventespresso.com/topic/category-description-not-showing-in-event/

But in another thread, the question of how to add the actual category or tag name is not solved:

https://eventespresso.com/topic/display-category-on-the-event-page/

Can you help us get the code snippet we need to make both categories and tags appear, and not just their description?

We are using the Genesis framework, if that helps anything.

Thank you


Tony

  • Support Staff

July 21, 2021 at 11:23 am

Hi there,

I think you are looking for something like this:

https://gist.github.com/Pebblo/042f04c9af5d03a70206e681ee28af84

Within THIS condition, you have WP_Term object in $term, thats looping over each ‘event category’ and you’ll have all the details you need within $term. use var_dump($term) or similar to see all of the options you have available from that object.

Within THIS condition you have a EE_Term object in $tag. Same as above in that you have all of the info you need for each specific tag on that loop and can output various details.

Does that help?


BCPTA

July 22, 2021 at 3:21 pm

Thank you Tony. However, while I can get by with code snippets and sometimes I can make out where to add a post ID or something like that, I’m not really a php coder. So what you explained after giving the link is beyond me. If I use the code in the link you gave, would that do the trick? Is there more I need to customize? Is that why you’re giving the extra info?

It just seems like it should be a fairly straightforward, simple thing, to add categories on a post in WordPress, including event posts. I’m not clear why this isn’t just built in to your plugin already. But a code snippet is fine with us, as long as it can be used without needing to become a php developer.

We really appreciate your help and prompt responsiveness though. We’ve got only good things to say about your company and level of support.


Tony

  • Support Staff

July 22, 2021 at 3:45 pm

If I use the code in the link you gave, would that do the trick? Is there more I need to customize? Is that why you’re giving the extra info?

It all depends on how you want to output those details, the specifics of how, what and where you want to output the category/tag name, description etc changes what needs to be done.

The snippet as is will output something like: https://monosnap.com/file/qTfPalsv8IG64SEvQh45erIwlfFe7E

It just seems like it should be a fairly straightforward, simple thing, to add categories on a post in WordPress, including event posts. I’m not clear why this isn’t just built in to your plugin already. But a code snippet is fine with us, as long as it can be used without needing to become a php developer.

EE4 events are a custom post type, so a lot of the output, layout especially, is controlled by your site’s theme.

The tags applied are standard tags, if your theme outputs tags for posts it should also do so for EE4 events but it’s heavily reliant on the theme to do so by default. We’ve seen themes output specific details only for ‘posts’ and ‘pages’ which means they then exclude a lot of functionality from custom post types like EE events.

EE Categories are a little custom (they are a custom taxonomy), they won’t normally be output by default on most themes unless they handle custom taxonomies (some do). This was a design choice to keep EE categories separated from the default WordPress categories as it makes it easier to manage for you (the end user) but does mean to output them sometimes takes a little code.

We ‘could’ just inject all of the details everywhere but the problem is that the presentation layer is meant to be controlled by your theme, the more we step over that the more chance we have with conflicts (both EE and the theme outputting categories on the same page for example).

I do get your point, it is just a balancing act between overloading the page, dealing with potential conflicts and keeping the output ‘clean’.

If you let me now how you want to output the above details I may be able to tailor the snippet to your needs better.

We really appreciate your help and prompt responsiveness though. We’ve got only good things to say about your company and level of support.

Thank you for the feedback 🙂


BCPTA

July 22, 2021 at 5:56 pm

Thank you Tony.

The way we want to output the categories and tags is at the bottom of the event post, like Genesis would do ‘normally.’

If there is a category, then the category would show up at the bottom.
If there is a tag, then the tag would also show up at the bottom.

The code I referenced is currently showing the category description at the bottom of event posts.

We would want that area to show the category and tag names as well, but above the description.

It may start with “Event categories:” / “Event tags:” or something like that (I could manage changing that in the code you may try to to give me, if I wanted to).

If there is a parent and child category it could show the path like a breadcrumb.
So:

Parent category / child category.

And likewise with tags.

Does that sound reasonable? I’m not sure what else we need to describe but I’d be happy to give more details if need be.

Thank you again.


Tony

  • Support Staff

July 23, 2021 at 7:24 am

Genesis is a framework that outputs very little on it’s own, you’ll be running a theme on top of that framework. Looking at the site linked to your license it looks like you are using Agentpress Pro, can you send me a copy of that theme so I can see what it does?

Also, can you link me to a post that has the Category and Tag output you are looking for?


BCPTA

August 2, 2021 at 2:20 pm

which email should I use to send it?


Tony

  • Support Staff

August 2, 2021 at 2:30 pm

You can use support[at]eventespresso.com

If the file is larger than 10MB you may need to use a service such as WeTransfer (they host the .zip and an email is sent to the provided email to download).


BCPTA

August 2, 2021 at 4:26 pm

I sent an email


Tony

  • Support Staff

August 4, 2021 at 4:03 pm

Ok, so there’s a couple of issues here.

First, the details (or well actually, tags) are already output to the page, but the theme hides them for logged in users.

Second, because EE events use a custom taxonomy, the ‘normal’ shortcode being used for categories is returning nothing (so in fact both categories and tags are both being output, but there are no ‘categories’ to display).

So here’s a fix for the shortcode, a snippet to simply swap it out for another shortcode that supports custom taxaonmies:

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

That snippet hooks into genesis post meta, checks if the current post is for an EE event and then swaps out the meta shortcodes.

Then you’ll need to remove this:

.logged-in .entry-footer, p.entry-meta, .nav-previous{
    display:none;
}

From within your theme, its hiding the entry footer when logged in so you can’t see the event categories and tags being output.

Is that what you are looking for?

The support post ‘Add category and tag to event pages’ 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