If you are a beginner and don’t know how to disable image attachment pages in WordPress, this article will provide you with many useful methods to address this problem.
Why do you need to disable image attachment pages in WordPress?
In WordPress, whenever you upload an image to your website, it will automatically create 4 URLs (including 3 URLs for the images and 1 URL for the original post). As a result, users may click a link from Google and land on a page that shows only a single image. This makes your website look unprofessional. In addition, it has some negative effects on SEO. For example, it increases the bounce rate of your website.
For this reason, in today’s tutorial, we will share with you some of the easiest methods to disable image attachment pages in WordPress. Now, let’s dive into the following methods.
How to disable image attachment pages in WordPress?
Method 1: Disable Image Attachment Pages Using the All in One SEO Plugin
For many beginners, using a plugin to disable image attachment pages in WordPress is the easiest method because it doesn’t require you to write a single line of code.
In today’s tutorial, we recommend the All-in-one SEO plugin, which is one of the most effective and popular WordPress SEO plugins on the market.
To install this plugin, first go to Plugins > Add New page in your dashboard. Then use the search bar to find the All in One SEO plugin. Click the Install Now button and activate it. That was simple, wasn’t it?

Once the plugin is installed, go to All in One SEO > Search Appearance.

This will open the Search Appearance page. You will see a list of tabs at the top of the page; click on the Image SEO tab.

You will see the first setting ” Redirect Attachment URLs“. You can disable the setting completely, redirect to the attachment page or the attachment parent page.
We highly recommend redirecting to the Attachment Parent page. That way, when users access the image attachment page, they will be redirected to your article instead.
After that, don’t forget to click on the Save Changes button.

Method 2: Disable Image Attachment Pages Using the Yoast SEO Plugin
If you are not using the All in One SEO plugin to optimize SEO for your website, you may be using the Yoast SEO plugin instead. Luckily, the Yoast SEO plugin also has this feature.
Just visit the SEO > Search Appearance page from your WordPress admin panel.

Next, click on the Media Tab. You will see the Redirect Attachment URLs to the Attachment itself option. Simply click on the Yes option to turn it on.
Then remember to click on the Save Changes button at the bottom of the page.

That’s it, all the image attachment pages and other media attachments will be redirected to the parent URL itself.
If you don’t want to use WordPress SEO plugins, the best choice is to install Attachment Pages Redirect. After installing this plugin, it will automatically redirect users to the parent URL, with no settings to configure, when they land on an image attachment page in WordPress. In addition, if no parent page is found, the plugin will automatically redirect users to your homepage.
Method 3: Disable Image Attachment Pages in WordPress via Code Snippet
This method is suitable for those who don’t want to use too many plugins. To disable image attachment pages this way, first create a new file in your WordPress theme folder and name it image.php. If there is already an image.php file available in your theme, you only need to edit that file instead.
Next, you need to add the following redirect code to the top of your image.php file
<?php wp_redirect(get_permalink($post->post_parent)) ; ?>
After that, you have to save the image.php file and upload it to your theme directory by utilizing FTP or your WordPress hosting control panel.
Now, whenever users access your image attachment page, they will be redirected to the parent post.
Sum up
We have given you the simplest and most effective methods to help you disable image attachment pages in WordPress. If you want to learn about other image-related problems, you can access our detailed guide on how to fix common image issues in WordPress.
Additionally, do you want to own a professional website? Don’t miss our Free WordPress Themes where we provide hundreds of amazing, modern designs for your website.



