Ad for Tradeomics

Add a Custom URL to your WordPress Gallery Images

Now a WordPress plugin on Github: https://github.com/brewern/gallery-custom-link - This post has been updated now that the code is on Github.

By default each of your gallery images either have no link, file URL, or post URL. You can see this by viewing the images you have attached to your page. What if you wanted a custom link for each image in your gallery. This would be helpful if you wanted a gallery image to have an outbound link or link to a page on your site.

I read a few blog posts looking for this solution, one or two steered me in the right direction. Forgive me for not linking to those sources as I cannot remember how I found them.

After you have installed this plugin, upload a few images and add a gallery to your page. Edit that gallery and you can see the new text field we have added. Here is a before and after:

Before

After

One last change to get the gallery to start showing your new custom link. Go to the HTML tab of the WordPress Wysiwyg and change the gallery shortcode link attribute to “custom_url”.

Change Gallery Shortcode

Important Note: Keep in mind that this plugin uses and overrides the core gallery function. Future WordPress versions could break this plugin, although it has lived through several. I’ll try to fix this plugin as soon as possible if it does break from an update. Leave a comment here or on Github in the event that it does break.

Enjoy.


  • Tony

    Great idea…this is exactly what I and many others are looking for, however where do I put the “add_filter” lines? Clearly, these do not go into functions.php

  • http://www.nick-brewer.com Brewern

    @Tony: Yes you put the “add_filter” lines in the functions.php file. All of the code above goes into your functions.php file.

  • Dustin

    Have you thought about making this a plugin? Also, everything appears to be working correctly for me except the last step. When I add link=”custom_url” to the shortcode I am getting the image attachment page (default) link. Any ideas? Thanks!

  • http://www.nick-brewer.com Brewern

    @Dustin Sorry about that and thanks for the catch. I forgot the add_shortcode function. The code has been updated.

  • Dustin

    Awesome – works great!

  • http://www.demo38.com Jonathon

    Thank you for this. By tweaking your second block of code here with the code hack I found here: http://blog.mattsatorius.com/technology/web-design/wordpress-gallery-shortcode-with-no-image-link/ I was able to then use link=”none” inside of the WP gallery shortcode to disable the links. Great stuff!

  • http://www.nick-brewer.com Brewern

    @Jonathon Great! Glad the post helped.

  • Eee

    this isn’t working for me. I pasted all of the above code in my functions.php file (within theme folders) and the custom link field displays in the image uploader window. But after adding [gallery link="custom_url"] thumbnails are still automatically linking to an attachment page….help please?

  • Eee

    NVM. I solved my own problem. Like an idiot I didn’t paste the code at the end of the file. I moved it to the bottom and it worked. THANKS SO MUCH!

  • http://nick-brewer.com Nick

    Glad it’s working for you.

  • Claudio Pascual

    Hello,
    your code was very useful for me, I used it as an inspiration for inserting a new field in the gallery detail for displaying and updating the slug (post_name).
    Cheers,

    Claudio

  • http://twitter.com/losetheflame Trista

    oh man.. I wish this worked with the polaroid plugin… but it didn’t. none the less, worked like a charm for the gallery. thank you!

  • Kate

    RAD!! I’d been searching for this exact thing. Thank you!! Took me a while to figure out I could just skip the second bit of code and just use:

    get_post_meta($id, ‘_rt-image-link’, true);

    as a variable in the plugin I’m modifying to pull from the custom URL. Thank you!!

  • Coatonasuanasua

    Works perfectly with WordPress 3.1! Many Thanks!!

  • Marco

    Is it possible to add the image right to the gallery?

  • http://nick-brewer.com Nick

    I’m not sure what you are asking. Could you be more specific?

  • Jehnuine

    Ok this is not working for me… what am I doing wrong? I copied the first code into the functions.php file and then I got a gnarly error. then I tried entering the second code below the first code in the functions.php and still got a gnarly error… please help.

  • http://nick-brewer.com Nick

    At the very least the first bit of code should not be giving an error. What version of WordPress are you running? This has only been tested for WP 3.0+. Double check to make sure all the code was copied and you’re not missing any closing semicolons.

  • Sebastian

    Thank You for the recipe, it really helps me re shopping cart theme.

  • Urquhart4

    This didn’t work for me. I copied the two post into my functions.php file. Then, it was showing text all over my wordpress dashboard. I signed out of the dashboard, went to the website and the code was showing up there.

    What am I doing wrong? BTW, i’m using WP 3.1.

  • http://nick-brewer.com Nick

    Could you send me a link to your site to see the error or link to a screenshot?

    If the code (php) is showing up on your website then you may have not pasted the above code within a tag.

  • Urquhart4

    thxs for the speedy reply. you were correct, i didn’t paste the code within the tag. Now that I’m seeing everything you have in the pics above. But I have another problem, when i click on the picture, it isn’t linking to the external page.

  • http://nick-brewer.com Nick

    Did you change the shortcode link to “custom_url”?

  • Urquhart4

    Yes, I added the [gallery link="custom_url" columns="2"].

  • http://nick-brewer.com Nick

    Is it linking to the image or to anything at all? Is there a way I can access your WP admin for you and see if I can figure out the issue. You can email me brewer.nick@gmail.com

  • Jehnuine

    My images are coming up as double….

    http://www.jehnglynn.com/

  • http://jehnuinedesigns.tumblr.com/ jehnuinedesigns

    Hi! My images on the homepage are showing up double and not linking anywhere..

    Please help!!
    http://www.jehnglynn.com

    (I thought I posted a comment the other day but I guess it did not go through…)

  • http://nick-brewer.com Nick

    It looks like you may have html in your link url which is breaking it. Or possibly left off some code when copy and pasting the code above. If you would like to email me a login I can take a look – brewer [dot] nick [at] gmail [dot] com

  • Hilmon

    THANK YOU SOOOOO MUCH!!!! This is exactly what I was looking for…. Works like a treat!!!! Now I just need to turn the gallery into a carousel… ha ha ha!!!! :-/

  • Sebastian

    Are you the developer.
    What theme are you using. Modest theme.
    Have you changed any of the templates, maybe the Page of page-loop template.
    Put site in maintenance.
    Use editor.
    Change the page.php and page-loop.php name to back up.
    Copy the page.php template and then the Page loop template from “computer to site directory where applicable.
    See what happens. If something is goes wonky you have the original files.
    That’s what I would try.
    I use twenty-ten. Once you get to know it is amazingly flexible. I assume modest has something like page.php

    Even better idea in appearance themes change to twenty ten theme and see if the images still double up.

  • http://wpgarage.com Rebecca

    Um… you are my hero! Thank you. It’s so ridiculous that this isn’t built in and that you have to do such a crazy workaround.

  • http://nick-brewer.com Nick

    You’re welcome. And I completely agree.

  • Jim

    I get Fatal error: Call to undefined function add_filter() in …./wp/wp-includes/functions.php on line 4501, which is part of the Custom Link :

    add_filter(“attachment_fields_to_edit”, “rt_image_attachment_fields_to_edit”, null, 2);

    I’m using a Graph Paper Press theme so I’ve no idea if they’ve modified functions.php so this wouldn’t work, but they did suggest trying your solution.

  • Tom

    help me! I tried this and now just get this error:

    Fatal error: Cannot redeclare gallery_shortcode() (previously declared in /home

    I can use my blog now can anyone help? I am sure its just me being stupid!!!

  • Tom

    fixed it!

    would still love to get this to work but ill settle with having my old site back!

  • Garry

    Hi Tom,

    I’m no expert, but of you can’t access you probably messed something in functions.php. To have your blog working back, simply replace the current functions.php with the original one of your theme. (do it throug ftp)

  • Warwick

    Hi, I had the same problem! It happened after I deleted an image from the gallery. After a lot of faffing I found that in HTML wysiwyg editor the “custom_url” entry had reverted to “file”. Change it back and it should work. If that doesn’t work try removing all the gallery images from the media library (last tab on the gallery editor) and re-uploading them. Then make sure that the “custom_url” bit is still there- it worked for me!

  • http://nick-brewer.com Nick

    I believe it may be that the shortcode “gallery” is already being modified in your theme, causing a conflict. Trying changing “add_shortcode(‘gallery’, ‘geekee_gallery_shortcode’);” to “add_shortcode(‘custom_gallery’, ‘geekee_gallery_shortcode’);” – then use [custom_gallery] as the short code in your post/page, don’t forget the other attributes in your shortcode.

    I will be rewriting all of the above code soon. I plan to filter the gallery to make my changes rather than just rewrite the whole function.

  • http://nick-brewer.com Nick

    That is odd. What version of WordPress are you running?

  • http://nick-brewer.com Nick

    Did you get this worked out? I tried accessing your site but it was down at the time.

  • Garry

    Hi,

    apparently I didnt go through the whole comment process. Thank you very much for this hack, but I got a problem. After following every step you give, my ulrs look like this : http://www.mydomain.com/www.thedomainIwanttolinkto.com.

    How can I fix that please?

  • http://nick-brewer.com Nick

    Sorry, Disqus requires the comment to be approved if it includes a link.

    The problem you are having is most likely caused from not having “http://” included in your link.

  • Irfan_bahalwan

    It doesn’t work!
    I’ve added the 1st code into functions.php, the 2nd code into media.php.
    And first of ll change the > into > , &amp into &.
    Then when I refreshed my back end, it shows error.

    It couldn’t execute the add_filter() functions

    I’ve commented the add_filter() functions, just to try it out, and it still has errors in media.php file

    FYI, I’, using WP 3.1.1.

    If you dont mind, could u post the modified functions.php & media.php that works in WP 3.1.1 here?

  • http://nick-brewer.com Nick

    All of the above code “as is” needs to go into your functions.php file, not the media.php file. There shouldn’t be any issues with WP 3.1.1.

  • Kermit Woodall

    I’m having quite a few problems with the code … it seems that many => and -> and && have been transcoded into =$gt; and -> and && and the like.

    Is there a download of this code, unaltered, that I could use?

    Kermit Woodall

  • http://nick-brewer.com Nick

    I added a pastebin link to the post. http://pastebin.com/smfPfwgW

    Sorry for the delayed comment or response to your email. We have been dodging tornadoes here in Arkansas.

  • Kermit Woodall

    Keep dodgin’! Thanks for the Pastebin but there’s still some transcoded problems and some double quotes where a single quote (or vice versa) should have been. You’ll see some && in some areas and at the top there’s an unnecessary <?php as well. I tried correcting it all but ended up with this, not quite right, Gallery page. http://www.morsepi.com/most-wanted/

    Thanks for the help!

  • Kermit Woodall

    Stupid DISQUS filter. I was saying there was an unnecessary < ? PHP at the top. Not an unnecessary Thanks for the help. :)

    Kermit Woodall

  • http://nick-brewer.com Nick

    Sorry about that. Check the link now, all of it should be cleaned up.

  • Kermit Woodall

    Still having problems – I think this line is wrong – might be others. Thanks!

    1
    $output .= "<a href="$link">$image</a>";

    Kermit Woodall

  • http://nick-brewer.com Nick

    Updated. Haven’t had a chance to test these minor fixes.

  • Alan

    Where do I have do insert the code insede functions.php ?? I copy and paste both codes but it doesnt work It makes the site stop working and i have to replace the functions.php file by the original via ftp.

  • Alan

    I have solverd this problem, but now i have another one. The gallery had 3 columns, but now it has only 1 and i cant make it have 3 columns again. What can i do?

  • Alwin

    Please, let me know where to paste the code in funcions.php

  • http://nick-brewer.com Nick

    Anywhere. I usually just paste it at the bottom.

  • Alan

    I have found a plugin that solve this problem, its the Gallery Just Better plugin

    You dont need to mess with the code anymore, just install the plugin and type the url link on the description of the images from the gallery. Then change the view to html and change the shortcode of the gallery to this one:

    [galleryjb link="url"]

  • http://nick-brewer.com Nick

    Awesome.

    Although keep in mind that you will be locked in to this plugin on your site, not sure how many pages/posts you will have or for how long. If support for the plugin stops it may be a lot of work to change over to something like what I have written above. The reason for not making my own shortcode is so that at anytime you can stop using the above code and have a regular gallery.

  • Chris

     I’m getting this error: Parse error: syntax error, unexpected ‘=’, expecting ‘)’ in /hermes/bosweb/web066/b661/ipg.echolynfannet/wp-content/themes/twentyten/functions.php on line 515

    Any ideas on what I’m doing wrong? I did paste the code at the bottom below the original function.php code using the http://pastebin.com/smfPfwgW

    Any help would be appreciated…thanks!

    Chris

  • http://twitter.com/rima_gerhard Rima Gerhard

    The problem with the code is that the icontag and itemtags weren’t being closed properly, here is the fix

    /* ——————————-
      MODIFICATION ################
      ——————————- */
      $image = wp_get_attachment_image($id, $size, false);
      $attachment_meta = get_post_meta($id, ‘_rt-image-link’, true);
      if($attachment_meta){
        if($attr['link'] == ‘custom_url’){
          $link = $attachment_meta;
        }
      }

      $output .= “”;
      $output .= “”;

      /* ——————————-
      MODIFICATION ################
      ——————————- */
      if($attachment_meta){
        $output .= “$image“;
      } else {
        $output .= $link;
      }

      $output .= “”;
      if ( $captiontag && trim($attachment->post_excerpt) ) {
        $output .= “” . wptexturize($attachment->post_excerpt) . “”;
      }
      $output .= “”;

  • FreedomTech

    Did anyone find the fix to the one column problem?  I have it too.  I have
    [gallery link="custom_url" columns="3"]
    but it still only give one column.

  • Urbn

    Fantastic code! did just want I needed.

    For those having problems with the error messages in the functions.php page the fix is easy.

    Most likely you are editing the wp-includes/functions.php (which is what I did at first).  You do not want to edit this file!

    Where you need to place this code  is the functions.php file inside your THEME.  You can edit (or create if it does not exist) wordpress-install/wp-content/themes/theme-name/functions.php

  • David Abbott

    In the last modification change the end of the line that begins

    $output .= “”

    from

    ‘;

    to 

    ”;

  • Jeff

    Yeah, I still can’t get the columns to work. Same issue as FreedomTech, with or without the code fix David Abbott proposed.

  • http://nick-brewer.com Nick

    Sorry you are having issues with this Jeff. I’ve been a bit busy lately, I will take a look at the issue and provide a solution in the next couple of days.

  • Jeff

    Appreciate it Nick. It’s so close to being perfect!

  • http://www.facebook.com/brianfrolo Brian Frolo

    I just solved the columns thing. Will post after dinner.

  • http://www.facebook.com/brianfrolo Brian Frolo

    I compared the page source for a standard gallery to the that created by Nick’s code. Certain tags were not closing. This http://pastebin.com/y96aDAnd does that. Thanks for creating a piece of awesomeness!

  • http://www.facebook.com/brianfrolo Brian Frolo

    And you need this too: http://pastebin.com/SWu3Q1QB

  • http://nick-brewer.com Nick

    Thanks Brian for modifying the code. I have updated the pastebin in the blog post with the revisions you have added.

  • Elizabeth229

    Hi – I’m having a little difficulty pasting the code in! I got a parse error that required me to re-upload functions.php via FTP (as someone else had mentioned they’d had to do).  Where specifically do the pieces of code get pasted?  I’m very much a newbie so help would be appreciated :)

  • http://nick-brewer.com Nick

    Copy the code from the link at the top of this article and paste into your functions.php file in your theme folder. The preview of code in the Article is converting “>” to “>”, looking at an alternative to display code.

  • Ally Reeves

    Truly Bummed. Tried to add this code and my whole WP site has crashed with a syntax error.  Was using 3.1 and have no clue what went wrong. Could you note *where* in functions.php this code should be placed? Top or bottom…

    Also unclear on 2nd bit of code. Are we taking anything out of media.php or are you just telling us you took something form there? This code post seems simple enough but alas it’s sunk my WP ship so please add some more detailed descriptions on how to make this add.

    thnx!

  • http://www.bluegrassinternet.com Chaley

    Awesome! Helped me out in a pinch!

  • Andy

    this is so close to working perfectly! pasted at the end of functions.php -  but there seems to be some kind of parse error – it shows two images and a closing ‘> – seems like a really simple fix, but i can’t work it out….

  • Andy

    on wordpress 3.2.1 – maybe that is the problem?

  • Silverfh

    simply super… I just used ths code to understand gallery function.. and now em doing my own gallery plugin…
    thanks a lot… 

  • Carolineniland

    Hi there,
    I’m using your code (taken) from the link above and pasted into my functions.php file.  I’m using WordPress 3.2.1 and I’m getting a double thumbnail of the image that I add the custom link too.  When I click one of the images it doesn’t go to the URL that I added into the custom field but has the following ending in the url <a%20href=   

    Can you help?  All the best, Caroline

  • chinny

    same issue as andy and carolineniland. double image and the url is broken. using WP 3.2.1

  • Muhammad Ashfaq

    how can i get custom link in my site ? it is working in admin panel…

  • chinny

    for anyone having the > issue. something to try: i went through my wp database and checked for rogue file paths. (i had moved servers and change the uploads directory in the settings). i also found that I was having the > issue on one image only. The rest were ok. I deleted that image and re-uploaded it with a new file name. everything is happy now.

  • http://nick-brewer.com Nick

    Sorry to hear that! Copy the code from the pastebin link at the top. Be sure you don’t copy “<?php" into your functions.php file if it is already at the top (most likely the case).

    Take nothing from media.php, that is just where I pulled the function from. All the code you need is found above.

  • http://nick-brewer.com Nick

    Sorry I am just getting back to you. Did you ever get this resolved? I’ve tested this in the latest version of WordPress with no issues. Be sure to copy the code from the pastebin link at the very top of this article.

  • http://nick-brewer.com Nick

    You are very welcome!

  • http://nick-brewer.com Nick

    Are you using the shortcode shown in the last thumbnail image? Not having “custom_url” as the link value in the shortcode can cause this.

  • http://nick-brewer.com Nick

    Thanks chinny for posting this solution. That is odd, not sure what would cause the image to be breaking things.

  • Jon

    I’m having the same problem, I wanted an image to link to a youtube video.

    I tried putting those two chunks of data at the bottom of the functions.php just above the closing ?> but I get an error when doing that

    Where and how exactly should I be adding it into the functions.php file?

  • Jon

    I see there are both a core and a theme functions.php. I tried adding to both, got the same error on the same line both times.

    “input” => “text”, // default

    Parse error: syntax error, unexpected ‘=’, expecting ‘)’

  • Jon

    Ah it works if I copy from pastebin.

    However is there anyway to automatically use the custom url if there is one present, rather than having to specify it with a shortcode. I’m using another plugin that automatically has the gallery on the page without using the shortcode and that is still using the original image link, not the custom one in the box.

  • http://nick-brewer.com Nick

    Glad to hear you got it working. I’ve got to figure out an alternative for code sharing in WordPress.

    You could try changing the line “if($attr['link'] == “custom_link”)” where “custom_link” is to the default, which I believe is “file”. So that line would read ”if($attr['link'] == “file”)”.

  • Jon

    Thanks Nick,

    Doing that change does make the thumbnail use the custom url as the link in a gallery on a normal blog post. It doesn’t work with the plugin I’m using but that would be a separate issue. I’ll have to just hope they fix the bug in the next wordpress update. 

    One thing that it doesn’t do though it work with the gallery lightbox as there is no rel=”lightbox” (or whatever rel value you need) on the link tag. I tried adding it to $output .= ”$image“; as that looks like the line which generates the html code but my php know how is limited and I couldn’t get it to work. Adding it in the custom url box just adds it to the hyperlink itself so that didn’t work either. Currently that one thumbnail in the gallery which links to a youtube video takes you to the youtube page rather than opening in the lightbox.

  • Esther

    So, I added the text to the top of my functions.php file, and this is the error I got when I tried to update a post – the custom url field showed up, I was able to modify it in my posts, but when I updated and went to preview, this is the error I got (full paths removed): 

    Warning: Cannot modify header information – headers already sent by (output started …functions.php:46) in …theme-editor.php on line 99
    Any ideas on what’s wrong?

  • Esther

    So, actually when I went to refresh my whole site, I got a different error – a syntax error – so I had to remove the <?php that was at the beginning of my file, since the code I copied and pasted already included a <?php opener. 

    That solved it!

  • Abbe

    I pasted code from pastebin in functions.php, but I dont see any Custom URL field in the gallery.

  • Abbe

    I solved it. For wp 3.2.1 I replaced and put the whole code in media.php instead of functions.php

  • ac

    hi abbe, i tried doing this and something’s going wrong… not an expert coder, just followed directions but must have done something wrong. i took the entire code from pastebin and pasted into the media.php, replacing the gallery shortcode that was there. where could i have gone wrong? thx

  • ac

     never mind! i had forgotten to change the gallery shortcode link….!!

  • Aimee

    Thank you for this code. It works wonderfully. I only wonder if it is possible to modify previous_image_link() and next_image_link() to also point to the custom URL instead of the default attachment page?

  • comercier

    Did you find an answer to the problem? I have the same error that Carolineniland (the double picture) plus that ‘> at the end of the file…

  • comercier

    Can you give more specifics on what you did I’m having a hard time trying to fix those same problems on WP 3.2… Thanx in advance

  • http://www.effutio.com ThePath

    I can confirm this works with WP3.3. Thanks dude, this save my bacon. I to however experienced the double image and the > displayed on the page. I can also confirm this was due to ommitting the new custom_url field in the shortcode: [gallery columns="2" size="medium" link="custom_url"] if you miss this out it will break, got nothing to do with dodgy urls etc as previously suggested in a comment

  • http://nick-brewer.com Nick

    You shouldn’t have to modify the media.php file, I recommend not changing any core files. All code modifications above should be within functions.php in your theme folder.

    After you have pasted all of the code you have to change the link value in your post shortcode to “custom_url”.

  • http://nick-brewer.com Nick

    Thanks for checking it in the latest WP update!

  • http://twitter.com/sev7en_com 尚7科技

    wp3.3 error:   ”input” => ”text”, // default     how to solved?  Thanks

  • Anonymous

    So I got it to work in WP3.3 however I am having the same issue of the double image and > being displayed and I was wondering how to fix this? I am still a newbie to php and any help would be greatly appreciated.

  • Anonymous

    Figured it out! A wonderful work around, thank you.

  • http://nick-brewer.com Nick

    Glad to here! Is the fix worth sharing?

  • Anonymous

    I just forgot to do the last step and change the gallery shortcode link attribute to “custom_url”. That fixes the double image issue, or at least it did for me.

  • Daniel Pol

    Great job. Thanks a lot.
    Yeap, works with 3.3

  • Kelli S.

    This works for me on 3.3 also. I really appreciate your work on this code!! It’s just what I needed!
    Thanks

  • AP

    Added the code to the theme folder as a custom-functions.php file. Works great, thanks for the post

  • http://www.facebook.com/alphaalec Alec Morrison

    This is holy crap awesome. Exactly what I needed for a client. WordPress needs to implement this fine piece of work. Many thanks!

  • Philip John

    I wish this was part of core ;) Any reason why it’s not a plugin and on WordPress.org ?

  • http://nick-brewer.com Nick

    I should probably get to that, it really should be a plugin… Didn’t expect so many people to need this.

  • http://www.facebook.com/naynayell Nikz Elliott

    Ohh god this is too much for me lol  I’m a complete
    noob, 0 PHP knowledge :( been trying to add the first code and I’m not even
    sure if it’s the right place to put it.

    Here is where I’m trying to put it:

    public_html/domain/wp-content/themes/theme/functions.php

     

    when I open it, there is only this –

     

     

    I tried adding code after “?>” and before, either

     

    If I put it before I get this error

    Parse error: syntax error, unexpected ‘=’, expecting ‘)’ in
    /home/cicomum/public_html/rpgflashgames/wp-content/themes/goodnews/functions.php
    on line 13

    And if I put it after “?>”

    I get this code on top of my dashboard

    Help please L(

     

     

  • http://vickistep.tumblr.com vickistep

    Hi. Thanks for all of the time you’ve put into this fix and answering questions.

    I’ve got the fix working fine on the default WordPress gallery, but when I activate a gallery plugin like Polaroid Gallery, which also uses the default gallery shortcode, I cannot get the custom URL to work. The images still link to the image files. Would you have any advice on how to make the plugin cooperate with the fix?

    See here: http://mcduffys.com/sample/

    I did try pasting your fix into the “polaroid-gallery.php” plugin file but it just did the same exact thing that it does now. The fix is currently pasted in my theme’s “functions.php”

    Sorry I know this isn’t your plugin but it seems that there are lots of people posting on the plugin forum looking for the same fix. I’d be happy to share my findings with them and a link back to your site.

  • http://nick-brewer.com Nick

    That plugin is either adding it’s own shortcode or overriding the default. I believe the only way to get it to work would be by modifying the polaroid gallery plugin directly. Which would require editing their existing code not adding anything new.

  • Barry

    Hi, Im running latest wordpress and latest theme Trending – the Input field in Gallery is visible after inserting this code into my Trending Theme functions.php, but does not recognise the new custom link url (HTML modified to: [gallery link="custom_url" columns="4"] )

    Any advice? This is such a great mod, its a winner as a plugin ;-)

  • http://nick-brewer.com Nick

    Hey Barry. I just finished moving the code into a WordPress plugin. Let me know if you are still having issues after adding the plugin. I’m not sure what could be the issue except for maybe if you are using another gallery plugin. https://github.com/brewern/gallery-custom-link

  • http://nick-brewer.com Nick

    I’ve moved my code into a WordPress plugin. Place the downloaded folder into your plugins directory https://github.com/brewern/gallery-custom-link

  • http://nick-brewer.com Nick

    It’s now a plugin! :)  https://github.com/brewern/gallery-custom-link

    I’ll work on getting on WordPress.org

  • Barry

     Hi Nick, thanks for the quick reply and the news on the plugin – I will definitely be using it.

    I managed to get the code to work with some changes suggested by the Trending theme author, so I think it was a theme issue. If anyone needs it I can post, but I guess not necessary with your plugin.

  • http://www.facebook.com/rferent Robert Ferent

    I, too, am a n00b and know virtually nothing about code. I believe I followed the install process correctly. I’m getting the following error in the gallery…

    Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, ‘GalleryCustomLink::rt_image_attachment_fields_to_edit’ was given in /miraclemen.info/wp-includes/plugin.php on line 170

    The plugin is in my “wp-content/plugins” directory in a folder titled “brewern-gallery-custom-link”. I’m using WordPress 3.3.1 with theme Twenty Eleven 1.3

  • shlomi

    from were i need do downloed the plg?

  • Jp

    by the way, the 170 line in the plugin.php file looks like this:

    $value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args']));

  • Jp

    im getting the same warning

    any ideas on how to fix it?

  • http://nick-brewer.com Nick

    Sorry about that, I rushed posting about the code and didn’t do some error checking. All is fixed and has been tested now.

  • http://nick-brewer.com Nick

    Sorry about that, I rushed posting about the code and didn’t do some error checking. All is fixed and has been tested now.

  • http://nick-brewer.com Nick

    Click on the Github link at the top of this article, then in the mid-header area of that page there is a “zip” download option. Click that link and you will get a zip file of the plugin.

  • Jp

    Thanks a lot man! im gonna try this right now!

  • shlomi

    hi
    Claim plugin should resolve after you have installed it is actually saving the imageTlink I wantBut once I’m up to and updating after I click the image appears an error:You do not have permission to access / wordpress 2 / <a href = on this server.What am I supposed to do all my site-based to a gallery of images on the main page and bereavement image linkAnother postI use warmserverPlease help me 

  • shlomi

    hi 
    thanks allot it what i need 
    afther i downlodad the post and click on the image 
    You don’t have permission to access wordpress on this server. 
    i workin on wampserver 

  • http://nick-brewer.com Nick

    I don’t think the issue is with this plugin. Check the php file’s permissions, does it match the permissions on other plugin files? Your OS may have the file permissions changed to something else as a result of the download and WordPress doesn’t like it.

  • Chappers

    I tried this a few days ago but it totally screwed my site – I ended up having to reinstall wordpress – bad times.  As others are saying how successful its been I guess I did something wrong with it.  Being a total newbie, can someone let me know how this is supposed to be installed?  Cheers

  • Chappers

    You know what, I’ve been a total moron…..!!  I did do something wrong with it!! Ooops!  Managed to get it installed now and it seems to work beautifully.  Cheers. I can’t believe this isn’t part of the standard set up.