Discover in this tutorial how to enable/disable the attachments page that WordPress incorporates since version 6.4 using code.
One of the new features of WordPress 6.4 is that it eliminates the attachments page. This setting only applies to new installations, so if you want it to apply it to a previous installation you have to use some code to get it.
Here’s how:
Snippet to disable attachment page in WordPress
Add the following code snippet to your functionality plugin:
To see this and another 1097 code snippets of this website, login or subscribe here.
If on the other hand, you have installed WordPress 6.4 or later and you want to retrieve the attachments page, this would be the code you need:
To see this and another 1097 code snippets of this website, login or subscribe here.
Conclusions
Do you want to prevent the WordPress attachments page from displaying? Here’s a simple way to do it.
And in case you want to enable it in WordPress 6.4 or later installation you also know how to do it.
If you have any question, please leave it in the comments. And if you want to give me a suggestion for future snippets, please send it through the contact form.
Benefits of being a subscriber. 🙂