Limited-Time Sale, up to 30% off! Go Pro, offer ends in | see announcement

Using Additional Custom Taxonomies

Events Manager automatically makes any taxonomy associated with events or locations searchable/filterable using our shortcodes and PHP listing functions.

Update : Since version 5.8 we have base classes you can extend and duplicate the features available in our own taxonomies, including uploadable images, color picking and associated placeholders. This tutorial is still accurate, but will be updated in the future to provide more information on extending our own classes. Meantime, developers will be interested in seeing how we do this with our own classes, such as with EM_Category and EM_Categories

Using other Plugins to help

There are various plugins which allow you to create custom taxonomies and associate them (or already present taxonomies) with existing custom post types. Since Events and Locations are custom post types, you can achieve the same effect using these plugins if you’d rather not add any code.

Two recommended plugins for the task are:

The end result is the same as coding this out, so we’ll explain what to do once you’ve added a taxonomy to Events or Locations further down.

Examples : Add existing taxonomies

We’re assuming you’ve already registered a taxonomy, or are using previously created taxonomies. We won’t cover registering a new taxonomy, for that, see the already-comprehensive instructions on the WordPress Codex.

The principle is exactly the same for any taxonomy you’d like to add, here’s the code:

function my_em_own_taxonomy_register(){
    register_taxonomy_for_object_type('custom_category',EM_POST_TYPE_EVENT);
    register_taxonomy_for_object_type('custom_category',EM_POST_TYPE_LOCATION);
    register_taxonomy_for_object_type('custom_category','event-recurring');
}
add_action('init','my_em_own_taxonomy_register',100);

Seriously, it’s that easy. What we’ve done above is add the ‘custom-category’ taxonomy to both Events and Locations, and is now available to your shortcodes and other object functions as custom_category .

Here’s another common example, adding the Event Tags and Categories that ship with Events Manager:

function my_em_own_taxonomy_register(){
    register_taxonomy_for_object_type(EM_TAXONOMY_CATEGORY,EM_POST_TYPE_LOCATION);
    register_taxonomy_for_object_type(EM_TAXONOMY_TAG,EM_POST_TYPE_LOCATION);
}
add_action('init','my_em_own_taxonomy_register',100);

Notice the slight difference here, which is we’re using constants to name the taxonomies, you could just as easily use ‘event-categories’ and ‘event-tags’, but since we define these as constants this is a ‘configuration-safe’ approach.

Exceptions : Post Tags and Categories

One final common example which has a slight twist – adding the normal posts category to your events and locations:

function my_em_own_taxonomy_register(){
    register_taxonomy_for_object_type('category',EM_POST_TYPE_EVENT);
    register_taxonomy_for_object_type('category',EM_POST_TYPE_LOCATION);
    register_taxonomy_for_object_type('category','event-recurring');
}
add_action('init','my_em_own_taxonomy_register',100);

Now your Events and Locations can assign and search for post categories. The twist is when using this in your search attributes, since we already use category and tag, you need to use post_category and post_tag instead.

Using Custom Taxonomies in searches

Once you’ve added the taxonomy to Events or Locations, it’s time to search! You can do this using shortcode or PHP. Here’s an example of both ways to search the post categories we added above.

Shortcode:

[events_list post_category=”featured,-hidden”]
[locations_list post_category=”featured,-hidden”]

Code:

echo EM_Events::output( array('post_category'=>'featured,-hidden') );
echo EM_Locations::output( array('post_category'=>'featured,-hidden') );

The two examples above search for events and locations respectively which contain the featured category but not the hidden category.

Note that when filtering with taxonomies, both events and locations are not considered here, only one or the other. That means if you want to filter locations by a specific taxonomy, you use location functions and shortcode and vice-versa.

26 Comments

  1. Dylan Barlett says:

    Does Events Manager do something that prevents a link to the term management page (edit-tags.php) for custom taxonomies from appearing in the Events sidebar menu?

  2. Iain MacDonald says:

    Thanks for this – hopefully very useful.

    I have been trying to get theme sliders to pull through events posts, and thought this was a great solution.

    It works in that I am able to assign regular post categories to events now, but when I set a theme slider to be based on that category, it still draws a blank.

    The issue is probably with the theme, but wondered if you could think of any reason that might be?

  3. Kevin F says:

    I am building an events feature in wordpress, and I am trying to simply get a specific event ID to post in a slider, so it shows the image and text (same info that is on the events page. I have been searching but cannot find a shortcode to call a specific event. Only the lists, categories, urls etc. I want the slider to show the event information, as I plan to show highlighted events on the homepage (4 or 5 events). Is this do-able?

  4. Jabi says:

    I just can’t believe this scenario has not been solved yet. I have an events venue. I´m using Events Manager to show my schedule and all I would like is a slideshow to show the upcoming events, lets say, the next X events’s featured images as slides, starting from the nearest upcoming event, making past events dissapear (and thus, adding new future events to the slider so I have it always showing X events). All I find is references to this outdated Smooth Slider plugin. No other solutions available? Thanks in advance.

  5. marcus says:

    The issue with what you’re asking for is that normal CPT queries that slideshow plugins would use search for posts/events by publish date, which isn’t the start date. You’d likely need to use PHP to create a custom WP_Query or use our functions to find the relevant post IDs of upcoming events and then feed it to a slideshow plugin.

    This post is related to taxonomies though, not sliders, so this question would be best directed to our forums.

  6. Eric says:

    Is it possible to use custom taxomomies for ordering event lists? For example if I had a daysoftheweek taxonomy, could I use it to order Monday events before Tuesday events?

  7. marcus says:

    Hi Eric,

    If you use our integrated search attributes e.g. in a shortcode, then yes it should order according to the order and orderby search attributes we offer:

    http://wp-events-plugin.com/documentation/event-search-attributes/

    You could order by date for example, however, you can’t order by taxonomy name, for that you’d need to do a regular WP_Query in PHP using their integrated taxonomy search options.

  8. Hello.
    I added to my functions.php this code:

    add_action(‘init’, ‘add_cat_into_events’);
    function add_cat_into_events()
    {
    register_taxonomy_for_object_type(‘category’, ‘event’);
    register_taxonomy_for_object_type(‘category’, ‘event-recurring’);
    }

    Now I can choose from the standard category Events Manager.
    How I can display the category name in the list of events?

  9. amelie says:

    Hi,

    I’ve created a new taxonomy but now I can’t find a way to display events which have a category from this new taxonomy. How can I create a template for this new taxonomy like category-single.php ? I’ve try also taxonomy-event-categories-stage.php but it’s not working. When I click on a category of my taxonomy in the menu I see the page with content-none.php.
    I’m using wordpress-3.9.1-fr_FR and events-manager.5.5.3.1.

    Thank you in advance for your help !

  10. christy says:

    Hi,
    I’ve seen a few posts looking for guidance on how to feed EM events to a slideshow – the Events Manager plugin homepage makes it look simple out-of-the-box, but there’s no straight-forward documentation on how to accomplish it. My theme comes with flexslider so I would like to display the event title, date, times, brief description and image within flexslider list items. I tried looking through the forums but there is no search form to ease the process? Can you help me?

  11. Elliot says:

    There’s a big oversight not mentioned in this tutorial.

    Custom Taxonomies can NOT be used with repeating events!

    http://wordpress.org/support/topic/showing-custom-taxonomies-on-recurring-events-page

  12. Rich Plakas says:

    Trying to add categories to locations either through post)categories or event-categories.

    While I am able to list them using either:

    post_category
    [locations_list post_category=”austin-breweries”]

    or

    category
    [locations_list category=”austin-breweries”]

    This works great!

    But locations map does not see this filter:

    post_category
    [locations_map country=”US” post_category=”austin-breweries”]
    Shows all Locations

    category
    [locations_map country=”US” category=”austin-breweries”]
    Shows No Locations

    Am I missing something to get this to work with maps?

    Thanks!

    • marcus says:

      Hi Rich, this should work. Please raise this on our forums and we can help you troubleshoot or reproduce this issue so it can get fixed.

  13. WP says:

    Can any1 help me in the following.

    1. Give away groupon discount ( 5tickets at the price of two ).

    2. Customize the whole search with custom attributes of event such as
    (Type(not category), Price(free|paid), age bracket ) etc. Which can me modified from admin

    3. Is there any way to display voucher code in the frontend of the website. So that when published from the admin it can be viewable to users.

    4. Custom emailed voucher for those who purchase above particular amount and can be used when they register next time.

    5. Can a user book more tickets after once booked for the same event.

    6. Front end managed user registration and login.

  14. joe says:

    That’s not to say it can’t be removed, but it requires some PHP on your part. You can probably remove it by hooking into the admin_menu action and making use of a function like remove_submenu_page.

  15. Someone Else says:

    After a
    register_taxonomy_for_object_type('category',EM_POST_TYPE_EVENT);
    another
    register_taxonomy_for_object_type('category','event-recurring');
    is needed.

  16. Domenico says:

    Hello, how do I recall featured category in single event templates?

    If I put: #_CATEGORYNAME calls me first in alphabetical order, while I put: #_CATEGORIES recalls all categories in alphabetical order …

    I would like to see only the main category.
    Thanks to all those who will help me.

  17. Ajay says:

    Hi,

    We have a Taxonomy called “Brand Title” which we are using for all CTPs(brands, Jobs, Reach Data, Gallery etc) . We added “Events” to use this taxonomy and we are able to see and assign it to every event. How do we display events filtered by “brand_title”? So we can display brand related events under each brand’s single page view.

    Rgds,

    AJ

    • marcus says:

      Hi Ajay,

      You’d do something like this – [events_list brand_title=”featured,-hidden”]

      If you’re still having issues please ask on our support forums.

  18. domenico says:

    I did everything and it works, but when I click custom taxonomy I open an empty archive page, how can I have a list of events in that taxonomy such as that category guy?

    thank you

  19. Richard Lane says:

    This tutorial doesn’t deal with custom taxonomies on multisite installations.

    There’s an undocumented filter “em_object_taxonomies” that the code says we need to use to allow a custom taxonomy to be accessed across a network of sites. I think it’s just a matter of adding an ‘ms’ element into the array which is used as a slug for the meta keys in the global em_meta table. I would welcome information on how we use this!

    • marcus says:

      Hi Richard, unfortunately it’s not a simple as changing that filter. MultiSite taxonomies that are available across the whole site is not a feature we support for taxonomies other than our own categories filter.

      With MultiSite, at the moment, any custom taxonomies are in the scope of the site it was created on, similar to how tags work.

      We’ve made some steps towards making this easier but we aren’t quite there yet.

  20. Petr says:

    Hi thanks for the usefull plugin. I registered the taxonomy, which can be edited in admin section of WP. But unfortunately did not find how to implement it to the event form (and probably to event display) spent some time here in support and google but to no avail.

    Any hints would be appreciated.

    Thanks

Leave a Reply

This comment area is for discussion, not obtaining support. If you are having issues installing or using Events Manager, please visit either our Free or Pro support forums and we'll be happy to help you there.



Interested in Events Manager?

Sign up to our newsletter, receive a free add-on and an additional 10% discount for Pro!

You will receive a confirmation email which you must click on, you will then be sent another welcome email with links to your discount and free add-on.