Home Forums Event Espresso Premium Template Tags for event meta

Template Tags for event meta

Posted: February 11, 2021 at 6:53 am


February 11, 2021 at 6:53 am

Is there any template tag to get event price, event time, and available space to register in the event?
I don’t see any of them here


February 12, 2021 at 12:41 am

I have managed to get the event time and date but still suffering to get the event price and available space for attendees to be registerd?


  • Support Staff

February 15, 2021 at 4:13 am

Hi Mark,

By available space for attendees do you mean spaces still for sale or in total?

If you have an EE_Event object you get both with something like:

// Spaces remaining for sale.
echo $event->spaces_remaining_for_sale();
// Total available spaces.
echo $event->total_available_spaces();

The price of an event is a little more tricky as you assign prices to tickets within an event, if you have multiple tickets which price are you showing?

// grab array of EE_Ticket objects for event
$tickets = EEH_Event_View::event_tickets_available( $post->ID );
// grab first ticket from array
$ticket = reset( $tickets );

//check if the ticket is free, if set the ticket price to 'Free'
if ( $ticket instanceof EE_Ticket ) {
    $ticket_price = $ticket->pretty_price();
    $ticket_price_data_value = $ticket->price();
    $ticket_price = $ticket_price_data_value == 0 ? __( 'Free', 'event_espresso' ) : $ticket_price;

echo $ticket_price;


February 16, 2021 at 3:49 am

I don’t have an EE_Event object on my page. Would you please tell me which class I have to include in the page file to create an EE_Event object?


  • Support Staff

February 16, 2021 at 4:23 am

Do you have a WP_Post object for the espresso_event post?

Aka a $post variable from the main query for an EE event post.

If so it should have the EE_Event object set as an additional property, so if you don’t have an EE_Event object but do have the WP_Post object for it, you can use:

if ($post instanceof WP_Post
    && $post->post_type === 'espresso_events'
    && isset($post->EE_Event)
    $event = $post->EE_Event;

$event should now be an instance of EE_Event for the current post.

However, we also have a helper method that can pull this in for you:

$event = EEH_Event_View::get_event($post->ID);


February 16, 2021 at 4:32 am

For this reply, I Must say Tony you are Awesome.


  • Support Staff

February 16, 2021 at 5:43 am

Thanks and you’re most welcome.

Something I do recommend when working with EE models/object (like the EE_Event object), is Kint:

Wrap your variable within d(); and you’ll get an awesome output that lists all of the methods available on the object.

It really helps find the method/property you want/need when working with the models:–Model-System

You must be logged in to reply to this support post. Sign In or Register for an Account

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3 Documentation for Event Espresso 4

Status: publish

Updated by  Tony 2 weeks, 1 day ago ago

Topic Tags

Tagged: ,


This topic is: resolved
Do NOT follow this link or you will be banned from the site!