Plugin Directory

Test out the new Plugin Directory and let us know what you think.

WP Gallery Custom Links

Specify custom links for WordPress gallery images (instead of attachment or file only).

#1) Will this plugin work with my theme's galleries?

Possibly. WP Gallery Custom Links plugin was designed for use with 1) WordPress's [gallery] shortcode and 2) images uploaded through the WordPress media manager. Some themes use these features, and others have their own proprietary way of saving gallery images and drawing out the gallery. Provided your theme meets the criteria above, the plugin should work with it. You might also want to see #6 below.

#2) Will this plugin work with NextGen galleries?

No, this plugin is not compatible with NextGen galleries. WP Gallery Custom Links was designed for use with 1) WordPress's [gallery] shortcode and 2) images uploaded through the WordPress media manager. NextGen galleries uses its own [nggallery] etc. shortcodes that function outside of the WordPress [gallery] shortcode.

#3) When I enable the plugin, the styling on my gallery changes. Why?

The way the plugin works requires the gallery generation code to be run twice. This may result in it being labeled as "#gallery-2" instead of "#gallery-1." Check your HTML and CSS for these changes and adjust accordingly.

#4) I'd like to use the custom link in my own gallery code or in a different custom layout. How can I get the custom link?

The custom links are stored as meta values for images, and can be accessed with the following:

$custom_url = get_post_meta( $attachment_id, '_gallery_link_url', true );

Please note that "$attachment_id" is a variable for the post ID of the image - you will need to have already defined and set this variable in your own code and use your variable in this spot. "$attachment_id" is just an example of what it could be named.

#5) I've set my gallery to remove Lightbox effects, but they are still coming up, possibly with nothing in them. Why?

Version 1.9 (hopefully) resolves most of these issues, but if you're still having this problem, see #5 in the old version's readme file here: http://plugins.svn.wordpress.org/wp-gallery-custom-links/tags/1.8.0/readme.txt.

#6) When I enable the plugin, nothing in my gallery changes, even though I have custom links set. Why?

Thing to try #0.5: make sure your gallery is using the [gallery] shortcode (i.e. you've created the gallery by clicking the "Add Media" button and then "Create Gallery" on the side of the media pop-up window). If you don't see a [gallery] shortcode in your content and/or you've created the gallery by using a custom form or shortcode generated by your theme (e.g. "I selected 'Gallery' as a page template option in a dropdown" or "I'm seeing [somethemename_gallery] in my content"), chances are this plugin will not work with that custom code - you would need to contact the author of that custom code to request they add their own version of custom links that will work with their code.

Thing to try #1: make sure your gallery is set to use either attachment or file links. If the gallery is set to link to "none" there will be no links to match on, thus this plugin won't be able to swap in custom values.

Thing to try #2: make sure you have the onclick effect set to "remove" if you continue to have undesired lightbox/carousel popups.

Thing to try #3: make sure the hook that this plugin uses (the "post_gallery" filter) is being called. Some themes and gallery plugins have code that replaces the default WordPress gallery code, and the post_gallery filter gets left out, which means this plugin never gets called to do anything. If you do a "View Source" on your gallery page and see a javascript file named "wp-gallery-custom-links.js" being included, but items you know have custom links are not using the custom links, try looking around in your theme/gallery plugin to see if the gallery shortcode is being replaced, and if that function doesn't contain a reference to post_gallery, try adding this near the top of the function (assumes the attributes variable passed to the shortcode function is named "$attr"):

$output = apply_filters('post_gallery', '', $attr);
if ( $output != '' )
    return $output;

You may want to see http://wordpress.org/support/topic/wont-work-syntax-error for an example of adding this code.

This thing to try is a bit on the programmy side, so if you're having trouble, my suggestion would be to contact your theme author and ask that they support the "post_gallery" filter in their gallery shortcode function. This would not only fix it for your theme most thoroughly, but would also fix it for any future users also using that same theme. Otherwise, any WordPress developer should be able to help you with the code changes to customize your theme to support the post_gallery filter like WordPress core (not something I consider in the realm of free support, sorry).

#7) The custom links are working fine, but I need help changing the formatting/styling on my gallery, such as spacing between images, aligning images, or changing image size.

This plugin just changes links, plus a bit of auxiliary functionality to help with changing the links. It doesn't alter layout or styling - that's something you'd need to change in your theme or whatever plugin you may be using to display the gallery. Note: if you're using [none] to remove links from gallery images, it may affect the styling, depending on whether your stylesheet is expecting all gallery images to have <a> tags around them, in which case you would need to modify your stylesheet to also apply the same styles to <img> tags without a link around them.

#8) I have a lightbox/carousel set up when a user clicks an image, and I would like to make the image in the lightbox/carousel window link to the custom link. How can I accomplish this?

Unfortunately those images are placed in those locations via your particular lightbox/carousel javascript library, which this plugin isn't able to hook into to modify. You would need to modify your javascript library or theme to accomplish this, which is outside the scope of this plugin.

Requires: 3.3.1 or higher
Compatible up to: 4.7.3
Last Updated: 2 months ago
Active Installs: 50,000+


4.9 out of 5 stars


7 of 9 support threads in the last two months have been marked resolved.

Got something to say? Need help?


Not enough data

0 people say it works.
0 people say it's broken.

100,1,1 100,2,2 100,1,1 100,1,1 100,1,1 100,2,2
50,2,1 100,1,1 100,1,1
50,2,1 100,2,2
100,1,1 100,1,1 100,1,1 100,4,4
100,2,2 100,1,1
100,1,1 75,4,3
100,2,2 100,2,2