cliffordp
9/21/2015 - 6:29 PM

Display Ticket image on event single page

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;
  }
}