• Hi there,

    I’m wondering if there’s a way to add a link to the featured image in order to open the image present in the post.

    Here’s the scenario. I’ve several posts, each of them has a featured image and an image in the post. So, the featured image shows up in the page and right now, if I click on it, it goes to the page.
    I want to avoid this, in fact what I need to do is, the user clicks on the featured image and that opens directly the image that’s in the post.
    Basically it works as a gallery, where the featured image is a sort of thumbnail and the actual image in the post is the full size image.
    Hope it does make sense.

    Any hints?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter verysame

    (@verysame)

    No one?

    Thread Starter verysame

    (@verysame)

    I assume there’s no way to do this which sounds kind of strange to me.
    I thought could have been a quite common case, how come WordPress doesn’t already come with an option like this?

    I hope this will help:

    <?php if (has_post_thumbnail( $post->ID ) ): ?>
    <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), ‘single-post-thumbnail’ ); ?>
    <img src=”<?php echo $image[0]; ?>” />
    <?php endif; ?>

    Thread Starter verysame

    (@verysame)

    Thanks Local Frame,

    I’m kind of lost, I was going to add the code you posted but in the theme root I can’t find any page.php or index.php.
    I only see this:
    footer.php
    functions.php
    rtl.css
    style.css

    and these folders:
    [languages]
    [js]
    [inc]

    Verysame have you created a page.php or index.php file?

    Thread Starter verysame

    (@verysame)

    Neither, I’m starting with the main theme, I was expecting to find an index.php which I don’t see.

    Thread Starter verysame

    (@verysame)

    Should I create an index.php even if the theme doesn’t come with one already?
    If so, what should I add to the index.php?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Add link to Featured Image’ is closed to new replies.