[WordPress] 外掛分享: Disable Media Pages

首頁外掛目錄 › Disable Media Pages
10,000+
安裝啟用
★★★★★
5/5 分(17 則評價)
225 天前
最後更新
問題解決
WordPress 6.0+ PHP 8.0+ v4.0.0 上架:2020-12-30

內容簡介

這個 WordPress 外掛完全停用「附件」頁面。

預設情況下,WordPress 會為每個附件建立一個頁面。這可能會有兩個不利因素:

搜尋引擎優化

附件頁面除了一張圖片外,沒有任何內容,因此幾乎沒有價值並可能會對 SEO 造成負面影響,因為它們是所謂的低質內容。甚至更糟糕的是,附件頁面有時可能會比實際內容頁面排名更高,這會導致糟糕的使用者體驗。

保留規範

附件頁面可能會意外保留站點上的規範。假設您上傳了一張名為 contact.jpeg 的圖片,WordPress 將自動創建一個附件頁面 https://example.com/contact。如果您稍後嘗試創建一個名為 Contact 的頁面,該頁面的網址將成為 https://example.com/contact-2,這並不好。

作法

這個外掛會自動將所有附件規範設置為唯一的 ID,以避免衝突。如果存取附件頁面,該外掛會設置 404 狀態碼並顯示「頁面不存在」的樣板。

您還可以對現有的任何附件規範進行調整,以免在未來造成任何問題。

感謝

特別感謝 Greg Schoppe 的研究和靈感,對開發這個外掛有很大的幫助。

支援外掛

維護 WordPress 外掛是一項艱鉅的工作。如果您喜歡這個外掛,請考慮在WordPress.org上評分。您也可以在GitHub 贊助者上支持我。謝謝!

如果您有興趣,也可以查看我的其他 WordPress 外掛:

Disable Customizer
Disable Drop Cap
ACF Image Aspect Ratio Crop

外掛標籤

開發者團隊

⬇ 下載最新版 (v4.0.0) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Disable Media Pages」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

Completely disable “attachment” pages created by WordPress.
By default, WordPress creates a page for each of your attachments. This is can be undesirable because of two reasons:
Search engine optimization
Attachment pages don’t have any content, except an image, so they provide little value and can negatively affect your SEO because they are so-called thin content. Even worse, attachment pages may in some cases rank higher than your actual content pages which leads to a poor user experience.
Reserved slugs
Attachment pages can accidentally reserve slugs on your site. Let’s say you upload an image named contact.jpeg, an attachment page https://example.com/contact is automatically created. If you then try to create a page named Contact, the URL for that page will be https://example.com/contact-2 which isn’t that great.
How it works
This plugin works by automatically setting all attachment slugs to an unique id, so they won’t conflict with your pages. If an attachment page is accessed, the plugin will set a 404 status code and display the “page not found” template.
You can also mangle any existing attachment slugs so they won’t cause any issues in the future.
WP CLI support
The plugin supports WP CLI.
Mangle existing attachment slugs
wp disable-media-pages mangle

Restore attachment slugs
wp disable-media-pages restore

Note for WordPress 6.4
WordPress 6.4 includes a new feature that allows you to disable attachment pages. However, this feature redirects attachment pages to the file URL instead of returning a 404 error. To completely disable attachment pages, you should use this plugin instead. The WP 6.4 feature also does not fix the issue where attachment pages reserve slugs for pages.
Also, there is not user interface to enable or disable media pages, they are automatically disabled for new sites but remain enabled for existing sites.
Because of these issues, I recommend you to use this plugin instead of the built-in feature. The plugin will be updated in the foreseeable future, at least until attachment pages are completely removed from WordPress core and older WordPress versions are no longer in use.
Thanks
Special thanks to Greg Schoppe for his research and inspiration that helped a lot with developing this plugin.
Support the plugin
Maintaining a WordPress plugin is a lot of work. If you like the plugin, please consider rating it on WordPress.org. You can also support me on GitHub sponsors. Thank you!
If you are interested, you can also check out my other WordPress plugins:

Disable Customizer
Disable Drop Cap
ACF Image Aspect Ratio Crop

延伸相關外掛

文章
Filter
Apply Filters
Mastodon