Closed vinkla closed 1 year ago
Hey! I'm not sure about this yet because WordPress 6.4 hasn't been released yet.
This change in core should fix the issue with duplicate content on new sites but old sites will still have this issue. Enabling/disabling media pages is done using a hidden configuration flag and it's not exposed in the UI. I might update the plugin to use this flag in WordPress versions greater than 6.4.
It's still not clear if the change fixes the issue where attachment filenames reserve slugs from pages. If this issue still continues even if the attachment pages are disabled, that's one thing this plugin does better than the option in core.
Anyway, I still plan on supporting this plugin in the foreseeable future. I will probably update the readme to direct users to this new filter after 6.4 is released. We'll have to see if the slug issue persist. If it does the plugin might still have some value. If it's fixed in core then 6.4 will probably render this plugin mostly obsolete, at least for new sites.
It looks like someone made a copy of this plugin for people who use the Acorn framework: https://github.com/Log1x/acorn-disable-media-pages
At least according to this person the slug issue still persist on 6.4. But I'm gonna wait until the stable release is out. Beta and RC versions are not final and functionality might be changed before the final release.
I'm not sure about this yet because WordPress 6.4 hasn't been released yet.
WordPress 6.4 was released on November 7, 2023 (yesterday).
It's still not clear if the change fixes the issue where attachment filenames reserve slugs from pages.
I am unsure about new instllation, but I tried to add the filter on an installation that was upgraded from 6.3. Now all attachment page links redirect to the file instead.
Yeah my bad, I completely missed 6.4 was actually already released. I did some quick testing and here are my findings:
The issue where media files reserve slugs from pages still exists. For example if I upload an image called example.jpeg
, it will reserve the page slug example
, even if the attachment pages have been disabled (wp_attachment_pages_enabled
is 0
). This is so that the redirects still work (https://example.com/example/
redirects to https://example.com/wp-content/uploads/example.jpeg
). This is the same thing SEO plugin like Yoast do which I think is insufficient to fix the issue.
What's even weirder is that the redirection behavior only kicks in for users that are logged in. If I have disabled media pages via the core option and I'm logged, when I visit https://example.com/example/
, it will redirect me to https://example.com/wp-content/uploads/example.jpeg
.
However, if I'm not logged in, basically if I'm an anonymous user, when I visit https://example.com/example/
the attachment page is still displayed (!!!).
Could you check if this happens in your end?
It seems this is because read_post
capability is checked before the redirection is performed. Anonymous users don't have any capabilities so the redirection doesn't kick in.
If this is how this feature is implemented in the core then it's pretty half-baked and barely works as intended.
I tried it locally and you're correct. I can reproduce your steps. When I'm logged out and visit the /example
slug, the page displays the image as if it were a featured image. This update by WordPress was definitely half-baked. I wonder what they thought this would achieve. However, understanding how Automattic updates WordPress is a topic for another day. I'm glad this plugin will continue to exist.
I'm curious if disabling wp_attachment_pages_enabled
still serves a purpose. Will you include it in this plugin?
I have released a new version of this plugin that is compatible with WordPress 6.4. Basically only thing this fixes is the following case.
The fix disables redirection in this case and instead displays the 404 page.
Otherwise, the plugin currently has following advantages over the core feature:
Core devs will probably fix the first issue on a patch version but even after this, points two and three still stand. I have written a comment about the logged-in problem in the WordPress issue tracker.
I'm curious if disabling
wp_attachment_pages_enabled
still serves a purpose. Will you include it in this plugin?
I don't think this is necessary because only thing this changes is the redirection logic. This plugin bypasses that completely because I want to show a 404 page instead.
Great! Keep up the good work Johannes 🙌
https://make.wordpress.org/core/2023/10/16/changes-to-attachment-pages/
Is this change rendering this plugin obsolete? For existing sites we can probably just add a filter: