Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

How to Automatically Remove Default Image Links in WordPress

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
How to Automatically Remove Default Image Links in WordPress

WordPress makes it super easy for you to upload images and create image galleries. However, one really annoying part about adding images to WordPress posts is that it automatically links the image to the media file. You can uncheck this option when adding an image, but sometimes you simply forget to uncheck it. In this article we will show you how to automatically remove default image links in WordPress.

Why You Should Disable Default Image Links in WordPress

By default, WordPress links images to themselves. A user sees that the image is a link, clicks it and they are then taken to the image file. From this page the user has two options: click the ‘back’ button in their browser or move on to another site. Usually it is the latter. It also affects your image SEO traffic because search engines could redirect users to the link used for the image instead of your post. Overall, it creates bad user experience and affects your site’s bounce rate.

One solution is that you simply select the option disable the link each time, but it is not feasible because sometimes you simply forget.

Removing default image link option in WordPress

Removing Default Image Link in WordPress

It is very simple to disable the default image linking behavior in WordPress. All you have to do is add this code snippet in your theme’s functions.php file or in a site-specific plugin.

function wpb_imagelink_setup() {
	$image_set = get_option( 'image_default_link_type' );
	if ($image_set !== 'none') {
		update_option('image_default_link_type', 'none');
add_action('admin_init', 'wpb_imagelink_setup', 10);

Another way to do this is by installing and activating No Image Link plugin. It works out of the box and there are no options to configure. However, the plugin runs the option on every page, so it is better to simply add the code on your own.

Hopefully this will make adding images in WordPress a little less annoying specially if you never link to images. Do you link to image files on your site? Let us know by leaving a comment below.

Source: Norcross

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »


  1. Raul Canessa says:

    Is there any way to change the image link to none in uploaded images. My site has over 1000 posts and I do not want to do it manually.


    • WPBeginner Support says:

      If you have already added the images to your WordPress posts and pages, then you will have to manually remove the links.

  2. Swadesh says:


    I have added this code into functions.php as per your instructions but images link URL is still running.


  3. Sarah says:

    Heya, I just tried doing this and my website totally crashed. It took me forever to figure out how to adjust the functions.php file back to normal using cPanel, and then I had to recreate my child theme. Any suggestions as to how I could unlink all my images at once without using php? The No Image Link Plugin seems to be fairly old now (last updated 1 year ago).. Cheers!

  4. Marlene says:

    Thank you thank you thank you! I saw this post ages ago and have always been terrified to attempt any coding. Finally took the plunge and it worked like a charm! Such an amazing time saver!

  5. Patton McGinley says:

    I can’t even find a “Link To” option for individual images in WordPress 4.3.1. Why does WordPress insist on making the image link a default in the first place?

  6. andy says:

    i very really need this tutorials to remove all link that’s in images post in wordpress.
    But, i have one question, is it work for the snippet of excerpt image ? eg. in homepage / archive, thanks. i need it to my blog

  7. Owais says:

    Is there anyway to remove image links, those are already done? Actually, I have around 500 pages in which I have image links. So, doing manually it’ll take time. So, please tell me is there anyway I can remove image links automatically?


  8. D Blake says:

    Should adding this code & clicking the blue ‘Update file’ button at the bottom of the window make the change instantly? I have added this code & clicked ‘Update file’, but after opening my site in a new browser window (as if I was a member of the public visiting my site) – making sure I’m not logged in with WP – the images are still ‘clickable’.

    Going back to the functions.php page where I added the code, after all the existing text, the code is not there!
    Looking closely at the content of the functions.php page, it appears to just be a page of instructions. There is no coded text on this page that actually appears on my site?

    • WPBeginner Support says:

      Functions.php file is a place where your WordPress themes stores functions or code it need to execute. Many of these things do not directly appear on your site but they support several features of your WordPress theme.

      Try to add the code again. When you click on the blue Update button, wait for a while to see the confirmation that file edited successfully.

      This code does not make links already added to images disappear. It will however, make it possible that when you upload an image next time in WordPress posts, they are not automatically linked. To remove the links from images you will still have to edit your posts and unlink the images.

  9. slewjo says:

    Hi there, I just added this code to my functions.php file and I can’t access my site now. I removed the code and still can’t access my site. Very scared. Please help.

  10. samira says:

    please i want to edit the gallary navigation because have downloaded a theme and have change the pictures in the gallary but if i click on the navigation button it goes to the theme website pictures not my website so i want you to help me find where i can located the gallary navigation to change it

  11. kathy says:

    It’s ok, all fixed, just deleted the code from file manager on cpanel,

  12. kathy says:

    Hello, I’ve added the code and now I can’t access my site. Can you please help me remove it. Thnaks.

  13. WPBeginner Staff says:

    You should paste this code at the bottom of your functions.php file. If your functions.php file has a ‘ ?> ‘ which is the closing tag for PHP, then paste the code before ‘?>’.

  14. Adam Dartez says:

    Man I really can’t find the answer to this question anywhere. Instead of using the media manager to handle my images I was wanting to put another folder inside my root domain, place all my images and videos inside it and then instead of uploading them from the post just link to them in that folder. For example in my root WP directory place an additional folder, say titled cdn, and if it was an image, say located at mywproot/cdn/image/imageiwanttoembed.jpg. Ive read that having a lot of image attachments pages is bad so that parts solved but would my images still be indexed by Google? Would my Yoast plugin still create a sitemap for my images? Does this even make sense? It would just be so much easier to manage as my site has a lot of images???

  15. Caroline V. says:

    Dear, I have I think the dumbest question.
    Where in functions.php shoud I paste the code?

    under or above something in particular?
    Or I just can paste it at line 1?

    Thanks :)

  16. Roeg says:

    Can this be done retroactively in bulk or do I have to go back to each image individually?

  17. metroholic says:

    Hi, what if instead of none I rather want the image to link to my post automatically? How should I go about it?

    • Rollingspoke says:

      Copy the URL to your post, select “Custom URL” under “Link To” and then paste the URL.

  18. Chris Pink says:

    Great, thank you. One more numpty possibility removed from the fingers of the user….

    A question; is it possible to do this in retrospect. ie is there a way of removing all links from all images blogwide?

  19. Zoran says:

    Hi, I’m a WP beginner and I used it in my child-theme functions.php and it works fine. Is there any way to apply the same in conjunction with tablepress cells containing? Any image that is inside of a tablepress cell still shows complete url. If you have any suggestions I would really appreciate it.

  20. Putranto says:

    Another option is to use plugin: Page Links To. This is handy for posts with featured image.
    There’s an option on every page to change the link to the target url or change to #.
    “Drawback” is, it changes not only the image link but also the post title link.

  21. Ozzy Musa says:

    Thanks man, it is labor intensive when I have to unlink all images I attach to a post due to WordPress automatically linking to the images. The fact that you mentioned it also affects SEO is shocking, no wonder i have been getting little image search traffic. Most people were being taken to the image directly and not the actual pages that images are on. Almost an problem I search for on Google comes up at the very top page. Syed Balkhi should be named KING OF WORDPRESS as he has tons of valuable tips and tutorials on wordpress.

  22. Mack says:

    Jason is Right. This code is not working. Please check and update it.

  23. Jason says:

    Syed, thanks for the article. I copied and pasted your code into my functions.php file and it broke my site. Is there a syntax error in your code that you know of?

  24. Håkon Stillingen says:

    Thanks for this.

    I am using attachment page with navigation controls as “gallery single picture view”. In my case clicking on the image on the attachment page leads to the image file, which I want to avoid. What would the approach to avoid this, using the same principles described in this post?

    Attachment page example –

  25. Zimbrul says:

    It’s a great tip as I often choose “none” for the images on the page unless I want to link them externally or they are part of a gallery.
    Will applying the code to the theme disable the other options of linking images or it’s just for the default case in which you don’t specify a different option for the image on page?

  26. Connie says:

    Thanks for that! I was searching for a function like that

  27. Travis Pflanz says:

    I have been using the following line of code to do the same thing:


    Why/how is your code snippet better?

  28. Praveen Prasad says:

    Is it necessary to add Featured Image for every post?

    • Travis Pflanz says:

      Necessary? It all depends upon your theme/need in the website. This snippet does not deal with the featured image. It refers to images added into the doby/content of the post/page.

  29. Anand Muglikar says:

    A lightbox also solves this problem and is more elegant.

    • WPBeginner Support says:

      Yes it cvould be an alternate. But a lightbox could also cause slow page load, search engines would still redirect users to attachment pages, lastly not all people are fan of lightboxes.

  30. jonathanwthomas says:

    I would actually like it to do the opposite – ALWAYS link to the image file. I use a lightbox gallery for all image links so readers can view the full sized version. Often, I forget – or my writers forget – to select ‘link to image file’ which my lightbox requires to work.

  31. Jami Howard Mays says:

    Can the site owner still enable image link on a per-use basis? On occasion, a client will want to make an image-style button and flipping over to the text editor to hand code the url into the image is a little out of reach for a few of my clients.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.