EE4 Custom Post Types

EE4 Custom Post Types

Any requests to get_posts of type ‘espresso_events’ or ‘espresso_venues’ automatically have an attached EE_Event or EE_Venue object, which contains extra info (like extra Event metadata, or Venue location data), and also has functions for easily getting related data.

For example, the EE_Event object has functions like is_active() (determines if the event is considered “Active” or not, taking into account the event’s status, whether all the datetimes for the event have passed, and other factors), tickets() (which retrieves all the non-archived tickets for that event), datetimes_ordered() (which retrieves all the datetimes for the event, ordered by time), etc. (See core/db_classes/EE_Event.class.php).

“Event CPT” data includes normal post data including:

  • Title
  • Description
  • Tags
  • Categories
  • Featured Image
  • Commenting
  • Excerpt
  • Custom Fields
  • Slug
  • Author
This data can be queried and displayed in themes along with other post data.

Taxonomies for events and venues

The espresso_event_categories custom taxonomy is registered for events.
The espresso_venue_categories custom taxonomy is registered for venues.
The post_tag taxonomy is also available to be used with Event Espresso events and venues.

How to change the “events” CPT slug

You can change the events slug by setting the Event Slug option in Event Espresso > Events > Templates. The slug option cannot be set to be event, which is the singular slug of the event custom post type.

How to change the “venues” CPT slug

You can add the above to a functions plugin or into your WordPress theme’s functions.php file.

How to change the template for the single event post

The WordPress template hierarchy will look for a single-espresso_events.php template before falling back to single.php, then singular.php, then finally to index.php.

You can set up a custom template design for the single event view by following these 3 steps:
1) Make a copy of the theme’s page.php or the single.php template and put the copy into the active WordPress child theme.
2) Rename the copy to be single-espresso_events.php.
3) Important: You will also need to add this line of code to your theme’s functions.php file:

add_filter( 'FHEE__EED_Event_Single__template_include__allow_custom_selected_template', '__return_true' );

How to change the template for the event list archive

The WordPress template hierarchy will look for a archive-espresso_events.php template before falling back to archive.php, then finally to index.php.
You can set up a custom template design for the event list archive by following these 3 steps:
1) Make a copy of the theme’s archive.php or the index.php template and put the copy into the active WordPress child theme.
2) Rename the copy to be archive-espresso_events.php.
3) Important: You will also need to add this line of code to your theme’s functions.php file:

add_filter( 'FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', '__return_true' );

Please be sure to set up a child theme before you begin to make theme modifications. When you keep your modifications within the child theme, your changes will not be overwritten should the theme need to be updated in the future.


Need more help?

Do NOT follow this link or you will be banned from the site!