When you upload an image inside your WordPress blog’s post, it becomes clickable. Let’s remove the link behind an image automatically so that, images inside the post doesn’t remain clickable anymore.
Why one needs this?
Have you ever heard about the word ENGAGMENT? Yes or No? Let me tell you when a visitor clicks an image inside your WordPress blog’s Post, that particular image shows up(With nothing else at that link) which makes the visitor close the tab and move away. What happens with that?
Why that bad?
- You start loosing your visitors
- Your site’s bounce rate increases
- Avg time of per visit decreases.
How to tackle this problem?
Goto your WordPress blog’s Admin panel and move to Appearance Tab >> Then Editor >> After that select Functions.php from the right side bar. Add the following code at its end, and then click Update
update_option( 'image_default_link_type', 'none' );
function no_atag_on_images($content){
return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content); }
add_filter('the_content', 'no_atag_on_images');
What this code will do?
It will remove a tag from every image you upload & include in the post. Like the image below has only img tag and no a tag.
FAQ
What about my old posts?
They will remain unchanged.
How will I add link to an image if I intentionally want to add one?
This code will not stop you from adding links manually to a blog post’s image. But one thing you can stay sure of is it will not allow automatic links to be included.
What if I want to add the image link to the image?
When you are about to insert the image in the post click File URL once :)
[ad1]
Your Turn:
- Did you like the tutorial?
- How much it affected your engagement?
10 replies on “Make WordPress Images Non Clickable Inside a Post”
this was problem faced by me ..i also googled it but no results ..thanks to you for sharing it with us…
i like this tip, it would help to engage your readers
Thanks for liking it Ali bhai. nice to see you here. :)
I hope so you enjoyed it. By the be ready for the next giveaway :)
My bounce rate was around 79%, but after implementing what you you said, it decreased by 2.7%. It did make a difference, thanks for that man
I hope so if you keep reading my blog you will get it decreased to about 30 to 40%
Good solution for this…. Maybe it could seem a not important issue but can help a lot. I think the pictures on your post are great to put a inner link. What do you think?
Is there a way to apply this change to old posts?
No
Hi, the code is working, but when I want to add new images the Media administrator doesn’t work at all.