Last active
May 9, 2017 05:57
-
-
Save cliffordp/013e3e43a3f3bca9b7cc to your computer and use it in GitHub Desktop.
Display Ticket image on event single page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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