Home Forums Event Espresso Premium Display available spaces in EE4 grid template

Display available spaces in EE4 grid template

Posted: July 15, 2016 at 2:37 am


July 15, 2016 at 2:37 am

I want to put code in EE4 grid template for available spaces in this web:
In other version, code was:

$num_attendees = get_number_of_attendees_reg_limit($event_id, 'num_attendees'); //Get the number of attendees. Please visit for available parameters for the get_number_of_attendees_reg_limit() function.
    if ($num_attendees >= $reg_limit) {
        <p id="available_spaces-<?php echo $event_id ?>"><span class="section-title"><?php _e('Available Spaces:', 'event_espresso') ?> </span><?php echo get_number_of_attendees_reg_limit($event_id, 'available_spaces', 'All Seats Reserved') ?></p>

But I don´t know put code in EE4 grid template as in this web (version event-espresso.3.1.20.P):

Thank you!!


  • Support Staff

July 18, 2016 at 9:54 am

Hi there,

You can display the available spaces in the EE4 grid template by copying the
espresso-grid-template.template.php file to your active WordPress theme.

Then you copy this code into the template just after the $datetime variable is defined:

if ( $datetime instanceof EE_Datetime ) {
    $limit = $datetime->get('DTT_reg_limit');
    $remain = $datetime->spaces_remaining( true );
    if ( $datetime->sold_out() ) {
        $remaintext = '<em>Sold out</em>';
	if ( $limit == EE_INF ) {
		$remaintext = '<em>A lot available</em>';
	} else {
    	$remaintext = sprintf( _nx(
    	    '%1$sOne space available%3$s', 
    	    '%1$sThere are %2$s spaces available%3$s', 
    	    $remain, 'event ticket info', 'event_espresso' ),
    	    '<em>', $remain, '</em>'

Then you add this code to the template to the spot where you want the tickets remaining message displayed:

echo '<strong>' . $remaintext . '</strong>';

The support post ‘Display available spaces in EE4 grid template’ 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.

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: closed

Updated by  Josh 3 years, 10 months ago ago

Topic Tags



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