I’ve tried several solutions that work for others that aren’t doing it for me.
Here is an example of the HTML I’m trying to affect
<dt class='gallery-icon'>
<a href='http://localhost/wordpress/?attachment_id=94' title='IMG_6032'>
The <a href
has to go, the image has to stay.
In my options link images is set to off.
The solutions I’ve read apparently don’t know what a gallery is in wordpress because its not the same as a list of images.
update_option(‘image_default_link_type’,’none’);
didn’t work.
neither did this
function attachment_image_link_remove_filter( $content ) {
$content =
preg_replace(
array('{<a(.*?)(wp-att|wp-content/uploads)[^>]*><img}',
'{ wp-image-[0-9]*" /></a>}'),
array('<img','" />'),
$content
);
echo $content;
return $content;
}
or this
function my_gallery_to_slideshow_settings( $params ){
$params['link'] = 'file';
return $params;
}
when I added the filters nothing happened.
The default wordpress Gallery feature adds a link to your images that seems to bypass these filters.
I’ve ran into this problem a few times as well. It took some searching, but eventually I found a super cool little plugin that makes it extremely easy to get rid of the anchor tags when using the gallery shortcode.
Install the plugin and activate it, then when you insert the shortcode, use this:
[gallery link="none"]
. After the plugin is activated all you have to do is add thelink="none"
to your gallery shortcodeYou can find the plugin here: http://wordpress.org/plugins/gallery-linknone/
You can disable the link using this bit of code in your
functions.php
:This will result in no
<a>
tag being inserted into the gallery html output.