Search

How to Add Hierarchical Categories for Event Espresso EE3

Listen to this article

event-espresso-hierarchyLet’s say you’re at Ikea (not online, but in an outlet), and you’re looking to buy a bookshelf. Would you roam around the store endlessly looking for bookshelves, or would you look up the ‘Living Room’ department, and head over to the bookcases right? Unless you’re a shopping nut, the simpler option is to make use of categories available, and quickly find the product.

Makes sense.

Ticket-buyers use the same logic on your events website as well. From a plethora of events, the easiest option for buyers to filter required events is using categories.

Now, if you’re using Event Espresso (EE3 or EE4), you know there is an option to add categories. All good there! However, EE4 users have an advantage because they can add hierarchical categories.

What are hierarchical categories you ask?

Let’s head back to the Ikea example. If Ikea is an events website on EE3 users can only filter events by one category- ‘Living Room’ department. And that’s it. They can’t filter it further. But using EE4, users can filter events by the category ‘Living Room’ department and then by the subcategory ‘bookcases’ to find the product they need. So the task for EE4 users become simpler.

I know there has been a lot of debate on the version of Event Espresso plugin you should be choosing- EE3 or EE4– to build your events website. But the possibility to add hierarchical categories should not be a reason to sway your vote.

That’s because you can add hierarchical categories in EE3 as well!

[space]

Event Espresso Add-On to Add Hierarchical Categories (EE3)

The task to create an add-on to add hierarchical categories to EE3 is not quite simple because events are not custom post types, and categories are not taxonomies. But that’s okay. We can work with that.

EE3 has its own tables where categories are stored. To create hierarchies we need to maintain our own table of categories and add a parent category field. To allow site owners to link parent categories to categories, the add-on would need to provide settings as well.

Let’s take a closer look at how the plugin would work.

[space]

How would the Add-On Work?

To add a category-parent relationship, we’ll need to add some settings in the admin panel. Ideally these settings would have to be placed under the Event Espresso menu. For example, we can add a ‘Manage Categories’ sub-menu in EE3. This can be done using the action_hook_espresso_add_new_ee_submenu hook.

We can use this option to display the category list and the hierarchy.

hierarchical-categories-event-espresso-ee3

Using an option to set the parent category, you can create category-parent pairs. There could be an additional option to set a child category as the parent category.

So, once the options are created, we’ll be saving them in our own table. The Event Espresso categories are not affected. All we’ll be doing is maintaining category-parent relationships. We can also add additional constraints, such as:

  1. A category cannot be set as it’s own parent.
  2. A child-category cannot be set as the parent for it’s parent category.
  3. A parent-category pair can be added only once.

Now, if you’re using the Events Calendar Add-on, these categories can be used as filters for events. There is some customization involved here too.

events-calendar-ee3-filters

Quite a nifty solution isn’t it? It might not be a complicated functionality but it can surely help improve user experience on your events website. And you know better user experience can surely help you increase sales. 🙂 If you have any questions regarding the implementation or are looking for additional help, be sure to write your questions and comments to me, using the comment section below!

Akshaya Rane

Akshaya Rane

One Response

Leave a Reply

Your email address will not be published. Required fields are marked *

Get The Latest Updates

Subscribe to our Newsletter

A key to unlock the world of open-source. We promise not to spam your inbox.

Suggested Reads

Join our 55,000+ Subscribers

    The Wisdm Digest delivers all the latest news, and resources from the world of open-source businesses to your inbox.

    Suggested Reads

    WordPress Tips & Tricks
    Ketan Vyawahare

    How to Make Responsive Tables using CSS without Tag Read More »