If you are a beginner and don’t know any way to disable image attachment pages in WordPress, fortunately, 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 to your website, it will automatically create 4 URLs ( including 3 URLs for the images and 1 URL for the original post). This way can make users able to click on the link from Google and all images will be displayed in a single image. This makes your website look unprofessional. In addition, it causes some negative effects on SEO. For example, it increases the bounce rate of your website.

For this reason, in today’s collection, we will share with you some 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 by 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 any line of code.

In today’s tutorial, we recommend utilizing an All-in-one SEO plugin that is one of the most effective and prevalent WordPress SEO plugins in the market.

In order to install this plugin, first of all, you go to Plugins > Add New page in your dashboard. Then use the search bar to find the All in One SEO plugin. Quickly click on the Install Now button and activate it. This was simple, wasn’t it?

Image11 1

Once the plugin was installed, switch to All in Once SEO > Search Appearance.

Image10

This will open the Search Appearance page. You will see a list of tabs on the top of the page, let’s click on the Image SEO tab.

Image12 1

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.

You highly suggest that you should redirect to the Attachment Parent page. Since 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.

Disable Image Attachment Pages In Wordpress 2

Method 2: Disable Image Attachment Pages using Yoast SEO plugin

If you are not using the All in One SEO plugin to optimize SEO for your website, you are using Yoast SEO plugin instead. Luckily Yoast SEO plugin also has this feature.

You just visit the SEO > Search Appearance page from your WordPress admin panel.

Image11

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.

Disable Image Attachment Pages In Wordpress

That’s it, all the image attachment pages and other media attachments will be redirected to the parent URL itself.

In case that you don’t want to use WordPress SEO plugins. The best choice for you is that you need to install Attachment Pages Redirect. After installing this plugin, it will automatically redirect users to the Parent URL without configuring any settings when they land on an image attachment page in WordPress. In addition, once there is no parent page to be 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 by using this way, initially, you need to generate a new file in your WordPress theme folder and name it image.php. In case that there is 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 any of your WordPress hosting control panels.

Now, whenever users access your image attachment page, they will be redirected to the parent post.

Sum up

We thoroughly gave you the simplest and most effective methods to help you disable image attachment pages in WordPress. If you want to refer to other problems related to images, you can access our detailed guide on how to fix common image issues in WordPress.

Additionally, are you desiring to own a professional website? Don’t miss our Free WordPress Themes where they provide hundred of amazing, modern designs for your website.

5/5 - (2 votes)
Lt Digital Team (Content &Amp; Marketing)
Latest posts by LT Digital Team (Content & Marketing) (see all)

Summer Sale Grab 50% Off for everything on today, don't miss it. Coupon code: SUMMER2024 Redeem Now
Last call: Summer Sale! Grab 50% Off for everything on today, don't miss it. Coupon code: SUMMER2024 Redeem Now