Skip to content

Instantly share code, notes, and snippets.

@cliffordp
Last active May 9, 2017 05:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cliffordp/013e3e43a3f3bca9b7cc to your computer and use it in GitHub Desktop.
Save cliffordp/013e3e43a3f3bca9b7cc to your computer and use it in GitHub Desktop.
Display Ticket image on event single page
<?php
// https://gist.github.com/cliffordp/013e3e43a3f3bca9b7cc
add_action( 'tribe_events_single_event_before_the_meta', 'forum_1005858_ticket_header_img' );
/*
could use different actions to output to different places on event single page
-- see /wp-content/plugins/the-events-calendar/src/views/single-event.php for more actions
-- also listed below:
tribe_events_single_event_before_the_content
tribe_events_single_event_after_the_content
tribe_events_single_event_before_the_meta
tribe_events_single_event_after_the_meta
*/
function forum_1005858_ticket_header_img() {
$ticket_header_img_id = get_post_meta( get_the_ID(), '_tribe_ticket_header', true );
if( 0 < intval( $ticket_header_img_id ) ) {
$output = '';
$output .= '<div class="single-tribe_events tribe-events-event-image">'; // put in a div to be able to center img (or could do display:block; on the image)
// adding these 2 classes adds-- clear: both; text-align: center; margin-bottom: 30px;
// might also want to add your own CSS to add margin-top: 30px;
$output .= PHP_EOL;
$output .= wp_get_attachment_image( $ticket_header_img_id, 'large' ); // could change 'large' to another image size that exists
$output .= PHP_EOL;
$output .= '</div>';
echo $output;
} else {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment