Created
June 5, 2018 14:40
-
-
Save joshfeck/2a32135aa2864d582deb547cc6db8081 to your computer and use it in GitHub Desktop.
Add featured image from venue onto the event 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 | |
//* 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_venue_details', 'my_add_featured_image_to_event_venue'); | |
function my_add_featured_image_to_event_venue( $post ) { | |
$venue_id = espresso_venue_id(); | |
if ( has_post_thumbnail( $venue_id )) : | |
if ( $img_ID = get_post_thumbnail_id( $venue_id )) : | |
if ( $featured_img = wp_get_attachment_image_src( $img_ID, 'large' )) : | |
$caption = esc_attr( get_post( get_post( $img_ID ))->post_excerpt ); | |
?> | |
<div id="ee-event-img-dv-<?php echo $venue_id; ?>" class="ee-event-img-dv"> | |
<img class="ee-event-img" src="<?php echo $featured_img[0]; ?>" width="<?php echo $featured_img[1]; ?>" height="<?php echo $featured_img[2]; ?>" alt="<?php echo $caption; ?>"/> | |
</div> | |
<?php | |
endif; | |
endif; | |
endif; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment