Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Created July 10, 2018 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshfeck/56f30f18ae87af1919c3c462618ee2de to your computer and use it in GitHub Desktop.
Save joshfeck/56f30f18ae87af1919c3c462618ee2de to your computer and use it in GitHub Desktop.
Adding spaces available on the event listing page
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_action(
'AHEE_event_details_before_the_content',
'ee_add_spaces_available_to_event_pages',
10
);
function ee_add_spaces_available_to_event_pages( $post ) {
$event = $post->EE_Event;
if ( $event instanceof EE_Event ) {
if ( ! $event->is_sold_out() && $event->is_upcoming() ) {
$html = '<div class="spaces-available">';
$html .= 'Spaces Still Available: ';
$html .= $event->spaces_remaining_for_sale();
$html .= '</div>';
echo $html;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment