How to Disable WordPress Attachment Pages in 2024 (And Why)

How to Disable WordPress Attachment Pages in 2024 (And Why)

Quick update on this topic as of 2024: WordPress 6.4 has introduced a notable change in how attachment pages are handled. For all new WordPress installations, attachment pages are fully disabled by default.

This only affects new installs – meaning users who installed their site recently and did so on WordPress 6.4 or newer from the start will have their attachment pages disabled.

However, if you’ve been running your site for quite a while and have just updated to WordPress 6.4 now, this won’t affect you. What this means is that for users like that, you still need to take action on your attachment page settings manually.

Below, I show you want you can do about that exactly:

How to test if you have attachment pages enabled

Go to your WordPress media library, click on any media file and look for this link:

View attachment page in WordPress
  • If the link is there, you click on it, and you get taken to a standard WordPress page with just the attachment file embedded, then you obviously have attachment pages enabled.
  • If the link is not even there, or it says “view media file” instead, then you have attachment pages disabled already.

Here’s why you should disable the attachment pages entirely

Previously, WordPress automatically created an attachment page for each file uploaded. For example, let’s say you create a post and add three images to it. WordPress then automatically creates four URLs – three for the images, and one for the original post.

This feature, while well-intentioned, often led to unnecessary pages that cluttered your site and search engine results without adding value.

Disabling attachment pages streamlines content management and improves the overall quality of search results for users and site owners alike. A small but impactful adjustment to keep in mind as you work on your WordPress site!

Here’s how to disable attachment pages if you still have them

Previously, most people used plugins for this. SEO plugins in particular have a lot of features built-in to do various things with attachment pages, but you can pretty much ignore all that in 2024.

Instead, the fastest way to disable attachment pages and end up with a clean site structure is to go to the options.php page of your site and do a quick edit there.

Don’t worry, though, you don’t have to edit the file by hand.

Instead, go to your wp-admin and simply add “options.php” at the end of your URL. For example:

https://YOURSITE.COM/wp-admin/options.php

⚠️ Warning, this is technically an important file for WordPress’ overall operation. If you’re not 100% comfortable here, it’s advisable to make a backup of the site beforehand. Here’s some advice on backups.

Here’s what you’ll see (the beginning of that page):

options.php pageoptions.php page

Find the line that says wp_attachment_pages_enabled:

disable WordPress attachment pagesdisable WordPress attachment pages
  1. Simply change 1 to 0 there.
  2. Click on save changes.

What this does:

  • As soon as you make this change, the attachment pages will be disabled, and all current attachment pages will be redirected to the raw URL of the attachment itself. (This is good, this is what you want).

That’s it! Done and done. 👌

Let me know if you have any further questions about this process.

Free guide

4 Essential Steps to Speed Up
Your WordPress Website

Follow the simple steps in our 4-part mini series
and reduce your loading times by 50-80%. 🚀

Was this article helpful?

No

Thanks for your feedback!

Karol K

Karol Krol is a writer, content strategist, and WordPress figure-outer with over 20 years of experience rooted in website building and web technologies. With his expertise underpinned by a master’s degree in computer science, he authored “WordPress Complete” – the ultimate WordPress handbook for newbies. His work has been published across numerous industry websites. He leads the editorial team at Themeisle.

Updated on:

March 28, 2024

Keep reading the article at Themeisle Blog. The article was originally written by Karol K on 2024-03-27 06:40:00.

The article was hand-picked and curated for you by the Editorial Team of WP Archives.

Disclosure: Some of the links in this post are "affiliate links." This means if you click on the link and purchase the product, We may receive an affiliate commission.

Leave a Comment

Your email address will not be published. Required fields are marked *

Show Your ❤️ Love! Like Us
Scroll to Top