Created
February 19, 2015 14:35
-
-
Save bordoni/ed06cb2e1a0316d733eb to your computer and use it in GitHub Desktop.
Showing Featured Images on the Month View
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 | |
/** | |
* Month Single Event | |
* This file contains one event in the month view | |
* | |
* Override this template in your own theme by creating a file at [your-theme]/tribe-events/month/Single_Event.php | |
* | |
* @package TribeEventsCalendar | |
* | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
die( '-1' ); | |
} | |
global $post; | |
/** | |
* We build and gather information specific to the individual event prior to | |
* the tribe_events_template_data() call to reduce the opportunities for 3rd | |
* party code to call wp_reset_postdata() or similar, which can result in the | |
* $post global referencing something other than the event we're interested | |
* in. | |
*/ | |
$day = tribe_events_get_current_month_day(); | |
$event_id = "{$post->ID}-{$day['daynum']}"; | |
$link = tribe_get_event_link( $post ); | |
$title = get_the_title( $post ); | |
$image_src = ''; | |
if ( function_exists( 'has_post_thumbnail' ) && has_post_thumbnail( $post->ID ) ) { | |
$has_image = true; | |
$image_arr = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'medium' ); | |
$image_src = $image_arr[0]; | |
} | |
?> | |
<div id="tribe-events-event-<?php echo $event_id ?>" class="<?php tribe_events_event_classes() ?>" data-tribejson='<?php echo tribe_events_template_data( $post ); ?>'> | |
<?php if ( ! empty( $image_src ) ) { ?> <a href="<?php echo esc_url( $link ) ?>" class="url"><img src="<?php echo esc_url( $image_src ); ?>"></a><?php } ?> | |
<h3 class="tribe-events-month-event-title entry-title summary"><a href="<?php echo esc_url( $link ) ?>" class="url"><?php echo $title ?></a></h3> | |
</div><!-- #tribe-events-event-# --> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment