Home › Forums › Calendar Products › Events Calendar PRO › Link featured image to event
- This topic has 5 replies, 4 voices, and was last updated 9 years, 5 months ago by
Mike DiNardo.
-
AuthorPosts
-
November 7, 2016 at 11:27 am #1188748
Mike DiNardo
ParticipantHi
We added the featured image to the Pro week-view and now need to have the image link to the event when clicked. Right now it just links to the home page?
We moved single-events.php to our theme according to your Themer’s Guide and added:
echo tribe_event_featured_image($event->ID, ‘thumbnail’, false);
to the output. We added false because when this parameter was set to true, it linked to the homepage instead of the respective event page.
We tried copying the tribe_event_featured_image() from general.php to our functions.php (renaming it to avoid conflict) file to see if we could change the url but we couldn’t figure it out. We also copied tribe_get_event_link( $postId = null, $full_link = true ) to our functions.php file…It seems like we should just be able to wrap the image in the same link as the heading tag, but we can’t get our heads around the filters…
$link is defined in function tribe_get_event_link but why does it seem to return ‘/’?function tribe_event_featured_image( $post_id = null, $size = ‘full’, $link = true ) {
if ( is_null( $post_id ) ) {
$post_id = get_the_ID();
}/**
* Provides an opportunity to modify the featured image size.
*
* @param string $size
* @param int $post_id
*/
$image_html = get_the_post_thumbnail( $post_id, apply_filters( ‘tribe_event_featured_image_size’, $size, $post_id ) );
$featured_image = ”;/**
* Controls whether the featured image should be wrapped in a link
* or not.
*
* @param bool $link
*/
if ( ! empty( $image_html ) && apply_filters( ‘tribe_event_featured_image_link’, $link ) ) {
$featured_image .= ‘<div class=”tribe-events-event-image”>‘ . $image_html . ‘</div>’;
} elseif ( ! empty( $image_html ) ) {
$featured_image .= ‘<div class=”tribe-events-event-image”>’ . $image_html . ‘</div>’;
}/**
* Provides an opportunity to modify the featured image HTML.
*
* @param string $featured_image
* @param int $post_id
* @param string $size
*/
return apply_filters( ‘tribe_event_featured_image’, $featured_image, $post_id, $size );
}function tribe_get_event_link( $postId = null, $full_link = false ) {
$url = Tribe__Events__Main::instance()->getLink( ‘single’, $postId );
if ( ” != get_option( ‘permalink_structure’ ) ) $url = trailingslashit( $url );
if ( $full_link ) {
$title_args = array( ‘post’ => $postId, ‘echo’ => false );
$name = get_the_title( $postId );
$attr_title = the_title_attribute( $title_args );
$link = ! empty( $url ) && ! empty( $name ) ? ‘‘ . $name . ‘‘ : false;
} else {
$link = $url;
}return apply_filters( ‘tribe_get_event_link’, $link, $postId, $full_link, $url );
}November 7, 2016 at 3:15 pm #1188841Cliff
MemberHi.
There’s a lot here, and I don’t think you need to use any filters at all.
I’ll provide some suggestions and you can let me know if they help or not:
Copy /wp-content/plugins/events-calendar-pro/src/views/pro/week/single-event.php to /wp-content/themes/[your-theme]/tribe-events/pro/week/single-event.php and then edit this new file to get started with the Themer’s Guide for Week View’s single-event.php
Then reference this forum thread to learn how to add the featured image to the $additional_data variable via tribe_event_featured_image().
November 7, 2016 at 5:24 pm #1188875Mike DiNardo
ParticipantThis reply is private.
November 8, 2016 at 3:19 pm #1189381Cliff
MemberThe Week View is horizontal by default. Here’s a link to our demo site’s: http://wpshindig.com/events/week/
And if you’re wanting the Week View in a different location, you could use the tribe_events shortcode.
Please let me know if this clears things up for you.
November 30, 2016 at 8:35 am #1199772Support Droid
KeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
AuthorPosts
- The topic ‘Link featured image to event’ is closed to new replies.
