Adding link to featured image in single entry

Home Forums Calendar Products Events Calendar PRO Adding link to featured image in single entry

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #111639
    Joseph Coppola
    Participant

    I found this post but it seems I am missing something.

    Modifying Links From Featured Image on Events Page

    I am trying to have the featured image link to the actual Event URL, I have used the following code

    “> <?php echo tribe_event_featured_image(); ?>

    But it seems that the tribe_event_featured_image() function also returns a hyperlink.. This a problem.

    Please tell me how to replace the feature image link.

    #111644
    Joseph Coppola
    Participant

    Here is the sample code… it didn’t through.
    “> <?php echo tribe_event_featured_image(); ?>

    #111647
    Joseph Coppola
    Participant

    [code] <a>"&gt; &lt;?php echo tribe_event_featured_image(); ?&gt; </a>[/code]

    #111653
    Joseph Coppola
    Participant

    It keeps cutting off my code… not sure how to paste code in here.

    #111908
    Barry
    Member

    Yes, unfortunately the forum isn’t the best venue for sharing code at present – using a service like Pastebin or Gist and dropping the link in here is usually best.

    You’re correct that our own tribe_event_featured_image() function returns a fully formed link. However, the featured images are like any others in WordPress – so you can substitute WordPress’s own functions like get_the_post_thumbnail() and any other suitably related template tags.

    Does that help?

    #111929
    Joseph Coppola
    Participant

    Ok. So then the post I linked to was wrong? That post said it would return the featured image… not a formed link.

    Since Im not a WP developer any chance you can tell me what the right code would be to display the featured image with a link to the Event URL?

    #112397
    Barry
    Member

    I think possibly you’re misunderstanding – it’s suggesting to strip out that function, precisely because it does return an image already wrapped up within a link. The basic pattern to wrap up the thumbnail in a link that points to the single event page would be:

    <a href="<?php echo tribe_get_event_link() ?>"><?php echo get_the_post_thumbnail() ?></a>

    If you are not doing this from within the single event page (where of course that link would be redundant) you may need to pass in the event ID to both of those functions:

    <a href="<?php echo tribe_get_event_link( $id ) ?>"><?php echo get_the_post_thumbnail( $id ) ?></a>

    I hope that helps 🙂

    #121036
    Barry
    Member

    It doesn’t look like you’ve got any further questions on this one and so I’ll go ahead and close the thread: of course if we can help with anything else please don’t hesitate to create new threads as needed. Thanks!

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Adding link to featured image in single entry’ is closed to new replies.