Skip to content

WordPress Gallery Shortcode with No Image Link

I was a little surprised today when I discovered that the wordpress shortcode for “gallery” had no option to have the images be no link at all, either fixed to “File” or “Attachment Page”.  I’m not a fan of editing the core PHP, but this is definitely a wordpress shortage.  Bummer about this hack is that if you upgrade WordPress, it’ll likely overwrite this change, but hey, my blog will still be here for ya.  Here’s how to enable gallery link=’none’ to work:

UPDATE – No more changing WordPress Core Files! Let’s get smarter here. This is now a PLUGIN!  Install by going to Plugins > Add New > search for “Gallery with No Image Links”

Whala – now you can use gallery link=”none” and the images not be forced linked to something.

Find this useful? Take just a moment and give a $1. Thanks!
Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
  • I am receiving this warning on the backend in wordpress

    Any ideas?Warning: Cannot modify header information – headers already sent by (output started at /nfs/c08/h01/mnt/126646/domains/ in /nfs/c08/h01/mnt/126646/domains/ on line866


    Sators reply on January 4th, 2012:

    This means you likely have a PHP error somewhere.  Check your PHP Error log to see if that shows anything…


  • Finally got around to creating this as a WordPress Plugin – You can download it here:


  • Look



  • Rusty Talent

    Thanks for the plug-in!


  • Fidel

    wow!!! there’s a plugin for everything it seems. Kinda cool when you spend 10 hours trying to figure something out. 


  • thunderkat

    THANK YOU…. 🙂


  • Lucas Balzer

    How about a link with no images? This code generates just a text link to launch a lightbox gallery. Usage:

    [gallery images="none"]HTML THAT WILL BE YOUR LINK[/gallery]

    add this to your functions.php:

    add_shortcode( ‘gallery’, ‘new_gallery_shortcode’ );

    function new_gallery_shortcode($attr,$content) {
    global $post, $wp_locale;
    $output = gallery_shortcode($attr);
    // remove images
    if($attr[‘images’] == “none”) {
    $output = preg_replace(array(‘/]*>/’, ‘/]*>/’, ‘/]*>/’,”/<a/"), array('','','',"<a rel="prettyPhoto[slides]""), $output);

    // this function adds prettyPhoto's API launch call to the wp_footer
    function your_function() {
    echo '
    $(function () {$(“.launch-slides”).click(function (){$$(“a[rel^=’prettyPhoto’]”).map(function(){return $(this).attr(“href”);})); return false;});});

    add_action(‘wp_footer’, ‘your_function’, 100);
    return ‘‘.$content.”“.$output;
    return $output;

    add this to footer.php (this is the prettyPhoto plugin initializer — different from the API launch command)

    $().prettyPhoto({YOUR PARAMETERS});

    Note: you must also install prettyPhoto ( for this particular snippet to work. If you’re using another lightbox, you’ll


  • Lucas Balzer

    sorry… the //remove images lines should read:

    // remove images
    if($attr[‘images’] == “none”) {
    $output = preg_replace(array(‘/]*>/’, ‘/]*>/’, ‘/]*>/’,’/<a/'), array('','','','<a rel="prettyPhoto[slides]"'), $output);


  • George Pau

    great plugin. thanks. stil… how can I remove the hover off the images ?


  • Hilmon

    I just commented out the if statement to automatically remove all links from all galleries …. very handy (for the particular project I’m working on) … Thanks 🙂


  • The plugin works like a charm!


  • lulu

    Thanks, the plugin is great! Is there a way to have only some of the images have no link and have the others link?


  • ertan hekimler



  • sitekickr

    Late to the party, but I just wrote a solution today which doesn’t require a plugin and does not require changing the core files. It involves adding a content filter in your functions.php file: