WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Turn image caption into a link (5 posts)

  1. sparkle92
    Member
    Posted 3 years ago #

    Hey everyone! I know similar topics have described a similar need, but they most commonly involve adding links to the captions.

    What I really need is to turn the caption itself into a link, pointing to the same URL as the image. So, whether you click the image or the caption you go to the same URL.

    I think the solution may involve hacking the gallery creation script in media.php , but I'm not that much into PHP and don't know how exactly to do this. The images on the site are like 5000 , so adding a link to each caption isn't an option (link stripping can be easier to shut down, but it's not exactly what I'm after).

    If there is some kind of plugin (which I haven't found) that would be great. If no, I'm open to your ideas. Thank you!

  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    how to link caption text to the link from caption image -

    building upon following article:
    http://www.transformationpowertools.com/wordpress/adjust-caption-frame-width

    possibly with this function added to functions.php of your theme:

    http://pastebin.com/CsANjhJk

    (not widely tested, no guarantee)

  3. sparkle92
    Member
    Posted 3 years ago #

    Hey, thanks for the suggestion. Unfortunately though, that didn't work for me. I've seen a similar solution while searching over the internet, but it didn't work either. Maybe it will help that ALL of my images are in galleries (no individual ones).

    You can see better what I'm trying to do here .

    Thank you!

  4. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    my suggestion was aimed at individual captioned images - i didn't fully get the idea that you are using a gallery.

    similar approach for the wordpress build-in gallery:

    http://pastebin.com/gvx0i3ub

    css addition to keep the appearance as it is:

    .gallery-caption a { color: #444; text-decoration:none; display:block; }
    .gallery-caption a:hover { text-decoration:underline; }

    (not widely tested)

  5. sparkle92
    Member
    Posted 3 years ago #

    Thank you so much! It worked. With a few tweaks on the styling I'll get exactly what I wanted. Thanks again!

Topic Closed

This topic has been closed to new replies.

About this Topic