WordPress.org

Ready to get started?Download WordPress

Forums

(Urgent)how Link images to blog post in gallery. (12 posts)

  1. justmailnaveen
    Member
    Posted 4 years ago #

    my question is regarding the default or internal gallery of wordpress.

    is it possible to link individual images in a gallery to external website or blog post.

    for eg :
    what i want is ,to be able to link images to other sites within the gallery so that when readers click the image in gallery they are taken to external site and not the full image view or description page of that image.

    I tried doing this in gallery tab via 'Link URL'
    but when i put the external url ,say http://www.yahoo.com
    and save and update gallery ,the image open the description page instead of yahoo.com

    Please help, my project has come to a standstill .

  2. kendoza1
    Member
    Posted 3 years ago #

    I have the exact same problem as described above!

    It is so infuriating, why can't anyone offer any explanation? It is so inconvenient for the gallery to link to the thumbnail image and not to the designated post or external weblink.

    When the link url of the post is entered on the image, when save or update gallery is applied the text entered disappears and the only link available is to open the thumbnail in a new window. Pointless!

    Can anyone please help with this request?

  3. Joseph
    Member
    Posted 3 years ago #

    Just tried it with version 3.0.1 and it works fine.

    @justmailnaveen
    What do you mean by description page?

  4. kendoza1
    Member
    Posted 3 years ago #

    Thanks for your reply Joseph, can you describe what you did?

    What I want is to have a page displaying images I use on my posts but as thumbnails as a gallery (an extra archive page of sorts), so that when the thumbnail is clicked it opens up the post which has that image and text on it.

    I too have version 3.0.1 and when I insert a gallery on a page, the link url I enter on each image to link to the post is ignored so that when the page is uploaded and you click on the image within the gallery it only opens the thumbnail image and has lost the url link to the post.

    Any help is appreciated.

    Cheers.

  5. Joseph
    Member
    Posted 3 years ago #

    Sorry, my mistake, I miss understood the problem.

    Link URL is for when inserting individual images and the gallery setting, link to image file or attachment page, overwrites it.

    You'll need to either hack the core files or find a plugin.

  6. kendoza1
    Member
    Posted 3 years ago #

    No problem Joseph.

    Does anyone know how to hack the core files or a plugin that can do what we are looking for?

    I have tried many plugins and cant find one that achieves this.

    Any help is very appreciated.

    Thanks.

  7. foochuck
    Member
    Posted 3 years ago #

    I'm also trying to figure out a solution for this. I have my gallery all setup, but I need to link to pages on my WordPress site instead of the image file or attachment page.

    -foo

  8. bjohnso
    Member
    Posted 3 years ago #

    That's exactly my problem, too. It seems that the default url is the url in the wp media library. I want a specific picture to go to a specific page on my WordPress site--not an external site.

  9. liperuf
    Member
    Posted 3 years ago #

    That was my problem also :)

    Unfortunately, there's no way to change wordpress' original behaviour. The alternative method, however, is quite simple: unset the original "URL" field and add a new, controllable, fashioned "URL" field.

    Write this code at your functions.php

    [Code moderated as per the Forum Rules. Please use the pastebin]

    To access it's value, try:

    $custom_url = get_post_meta($post->ID, '_custom_link', true);

    It's all about the right hook, people!

    Original idea from: http://wpveda.com/adding-custom-fields-to-wordpress-media-gallery-upload/

  10. decca1o
    Member
    Posted 3 years ago #

    @liperuf Thanks for the solution. Is the code in Pastebin expired? Nothing showed up for me. Also, I am not sure what to do with the $custom_url = get_post_meta($post->ID, '_custom_link', true);
    I appreciate any help ypu can give me. Thanks

  11. liperuf
    Member
    Posted 3 years ago #

    Sorry @decca1o. I forgot about pastebin bureaucracy.

    So, paste the code below in functions.php

    http://pastebin.com/aeQEMwhe

    This piece of code unset original URL field and adds another metadata-URL field.

    Then, you need to hook the "saving" process aswell (also paste this in functions.php):

    http://pastebin.com/DzTiAYxa

    And, finally, access it's value width:

    $custom_url = get_post_meta($post->ID, '_custom_link', true);

    inside any Loop, where $post->ID is an attachment ID.

    I hope it helps!

  12. decca1o
    Member
    Posted 3 years ago #

    That does help. I appreciate it

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags