Remove image links in wordpress.

Older versions of WordPress used to link images on your website to their files. That means users could click on an image and be sent to that file. This is not great from a user experience perspective, as it forces users to backtrack if they click on an image by mistake. To avoid that, you needed to know how to remove image links in WordPress.

We say “needed” because newer versions of WordPress no longer link to images by default. However, if you’re working with a website that’s using an older version of the Content Management System (CMS), you might want to know how to remove these links. 🔗

In this article, we’ll show you how to do that. We’ll be using a simple code snippet that you don’t need to modify, so don’t worry if you’re not comfortable with code. Let’s get to work! 👨‍💻

The easiest way to add custom code to WordPress is by using a plugin. This approach removes the need to edit core files, which can often result in unforeseen errors in WordPress. That applies particularly if you’re not used to dealing with code.

Our plugin of choice for this task is Code Snippets. This is a plugin that enables you to add code to your theme’s functions.php file without having to use FTP or accessing the server through your hosting control panel.

Once you install and activate Code Snippets, it’s time to add the code to remove image links in WordPress. Go to Snippets > Add New and set a title for the new snippet:

Add a snippet to remove image links in WordPress.

The code you need to add goes in the Functions PHP tab. Select that tab and copy and paste the following code inside:

function ti_no_image_links() {
    //Get the default image link setting in WordPress
    $image_links_set = get_option('image_default_link_type');
    if ($image_links_set !== 'none') {
        //Update the image link setting to 'none'
        update_option('image_default_link_type', 'none');
add_action('admin_init', 'ti_no_image_links', 10);

That is PHP code that uses the get_option function to get the value of image_default_link_type setting from the database. That setting determines if the images you add to WordPress include links by default or not.

If that setting isn’t set to remove image links, the code updates it. The code will run every time the WordPress admin loads.

After pasting the code, click on Save Changes and Activate. That’s it! The code will remove image links going forward.

Conclusion 🧐

Learning how to remove image links is simple. You only need to add a snippet of code (which we provide above) to the active theme’s functions.php file. If you’re not comfortable doing so manually, we recommend using the Code Snippets plugin.

Keep in mind that newer versions of WordPress remove image links by default. If you’re using an old version of the CMS, we recommend updating it. Using the latest version of WordPress will help you avoid running into compatibility issues. And, it will also give you access to new features such as full site editing, which will make your work easier.

Do you have any questions about how to remove image links in WordPress? Let’s talk about them in the comments section below!

Yay! 🎉 You made it to the end of the article!

Inline Feedbacks
View all comments

Or start the conversation in our Facebook group for WordPress professionals. Find answers, share tips, and get help from other WordPress experts. Join now (it’s free)!