I use a gallery shortcode in my index.php (theme directory) to display 3 boxes of images. The images are fetched from my Media.
<div class="well well-clear" style="padding-bottom: 0; margin-bottom: 0;">
<?php echo do_shortcode(''); ?>
</div>
By default these images have a hyperlink that when I click on it, a page will open and show the bigger version of this image. I don’t want this to happen. Is there any option that I need to modify so that it will not hyperlink?
I’m new to WordPress, please don’t be rough on me.
Update:
It looks like there exists an attribute
link="none"
after all 😉For example:
So we don’t need to reinvent the wheel, like in my previous answers 😉
Previous: Plugin to handle
link="no"
in the gallery shortcode:Here’s a demo plugin to add the option to remove the image links in the gallery.
You can use the
link="no"
option to remove the links, for example:Create the folder
/wp-content/plugins/gallery-without-links/
and add the filegallery-without-links.php
to it, containing the following code:Previous answer:
Here is one idea:
The gallery shortcode callback is using the
wp_get_attachment_link()
function to generate the link to each image in the gallery. We can therefore use thewp_get_attachment_link
filter to strip out the<a>
tags.You could then modify your code snippet to:
where:
I just had a similar problem, and I used CSS targeted at the ul applying
pointer-events: none;
.I’m using the gallery block and my current WordPress version allows to introduce custom CSS directly on each block, so I did just that. No need to do CSS hunting.