前言介紹
- 這款 WordPress 外掛「Single Category Permalink」是 2011-07-17 上架。
- 目前有 600 個安裝啟用數。
- 上一次更新是 2021-09-29,距離現在已有 1316 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 4.6 以上版本才可以安裝。
- 有 5 人給過評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
外掛標籤
link | category | permalink | structure | coffee2code |
內容簡介
這款外掛可以將連結 (分類或文章)的完整分類架構縮減為僅顯示最低階層的分類。
預設情況下,WordPress 會將自訂連結結構中的 %category% 佔位符號,替換為該文章的第一個符合的分類的完整分類架構。例如,如果網站的分類架構如下:
應用程式
|_ 桌面
|_ Web
|_ WordPress
若你的自訂連結結構設定為 %category%/%year%/%monthnum%/%day%/%postname%,而文章標題為「最佳外掛」且歸屬於「WordPress」分類,則文章的連結將會是:
https://www.example.com/applications/web/wordpress/2008/01/15/best-plugins
如果你啟用了 Single Category Permalink 外掛,則文章的連結 (且會被網誌所辨識) 將會是:
https://www.example.com/wordpress/2008/01/15/best-plugins
要讓分類成為文章連結結構必要的一部分,必須在「設定」-「永久連結」管理頁面中明確地定義 %category% 為自訂結構的一部分,例如: /%category%/%postname%。
對於分類連結,%category% 是被默認隱含為「分類基底」值 (或者是預設的分類基底如果沒有指定的話)。因此,如果你的分類基底是「category」,上述例子的分類列表頁面將會列出位於「WordPress」分類內的文章:
https://www.example.com/category/applications/web/wordpress/
如果啟用了這個外掛,作為連結的網址會變成:
https://www.example.com/category/wordpress/
注意: 完整分類和文章的連結將會繼續運作。這個外掛會對瀏覽器和搜尋引擎發出 302 導向重新導向至短網址。
相關頁面: 外掛首頁 | 外掛目錄頁 | GitHub | 作者網站
Hook
這個外掛提供一個適用的 Hook。使用這個 Hook 的程式碼最好放在 mu-plugin 或網站特定的外掛中 (超出本說明文件的範圍)。也可以將它們放在你的目前主題的 functions.php 檔案中。
c2c_single_category_redirect_status (filter)
這個 Hook 可以讓你指定重新導向所使用的 HTTP 狀態碼。預設情況下是 302。
參數:
$status (integer) : 預設的 HTTP 狀態碼
範例:
/**
* 將重新導向的 HTTP 狀態碼設為 302。
*
* @param int $code HTTP 狀態碼。預設是 301。
* @return int
*/
function scp_change_redirect_status( $code ) {
return 302;
}
add_filter( 'c2c_single_category_redirect_status', 'scp_change_redirect_status' );
原文外掛簡介
Reduce permalinks (category or post) that include entire hierarchy of categories to just having the lowest category in the hierarchy.
By default, WordPress replaces the %category% permalink tag in a custom permalink structure with the entire hierarchy of categories for the post’s first matching category. For example, assuming your site has a hierarchical category structure like so:
Applications
|_ Desktop
|_ Web
|_ WordPress
By default, if you have a permalink structure defined as %category%/%year%/%monthnum%/%day%/%postname%, your post titled “Best Plugins” assigned to the “WordPress” category would have a permalink of:
https://www.example.com/applications/web/wordpress/2008/01/15/best-plugins
If you activate the Single Category Permalink plugin, this would be the permalink generated for the post (and recognized by the blog):
https://www.example.com/wordpress/2008/01/15/best-plugins
In order for a category to be used as part of a post’s permalink structure, %category% must be explicitly defined in the Settings -> Permalinks admin page as part of a custom structure, i.e. /%category%/%postname%.
For category links, %category% is implied to follow the value set as the “Category base” (or the default category base if none is specified). So if your category base is ‘category’, the above example would list posts in the ‘WordPress’ category on this category listing page:
https://www.example.com/category/applications/web/wordpress/
With this plugin activated, that link would become:
https://www.example.com/category/wordpress/
NOTE: The fully hierarchical category and post permalinks will continue to work. The plugin issues a 302 redirect to browsers and search engines pointing them to the shorter URL.
Links: Plugin Homepage | Plugin Directory Page | GitHub | Author Homepage
Hooks
The plugin exposes one filter for hooking. Code using this filter should ideally be put into a mu-plugin or site-specific plugin (which is beyond the scope of this readme to explain). Less ideally, you could put them in your active theme’s functions.php file.
c2c_single_category_redirect_status (filter)
The ‘c2c_single_category_redirect_status’ hook allows you to specify an HTTP status code used for the redirect. By default this is 302.
Arguments:
$status (integer) : The default HTTP status code
Example:
/**
* Change the redirection HTTP status to a 302.
*
* @param int $code The HTTP status code. By default 301.
* @return int
*/
function scp_change_redirect_status( $code ) {
return 302;
}
add_filter( 'c2c_single_category_redirect_status', 'scp_change_redirect_status' );
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Single Category Permalink」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
2.0 | 2.1 | 2.2 | 2.3 | 2.4 | 2.5 | 2.0.1 | 2.0.2 | 2.0.3 | 2.0.4 | 2.1.1 | 2.4.1 | 2.4.2 | 2.5.1 | 2.5.2 | trunk |
延伸相關外掛(你可能也想知道)
Custom Post Type Permalinks 》自訂文章類型永久連結允許您編輯自訂文章類型的永久連結結構。, 更改自訂分類目錄的永久鏈接,以“example.org/post_type/taxonomy_name/term_slug̶...。
Custom Permalinks 》name or slug), add the filter that looks like this:, function yasglobal_exclude_posts( $post ) {, // Replace '2' with ID of the post you want to ...。
Permalink Manager Lite 》Permalink Manager 是一個高評價的 WordPress 永久連結編輯器,可讓使用者自定義文章、頁面和自訂文章型別的網址(專業版支援分類法)。若要讓您的網站被搜尋...。
FV Top Level Categories 》這是針對 WordPress 3.1 及以上版本修復「Top Level Category」外掛程式的修正版。此外掛程式的目的是提供和原來程式相同的功能,但在新版本的 WordPress 上...。
WP No Base Permalink 》該外掛能夠將分類基礎從您的分類永久連結中移除 (可選)。默認情況下啟用。, 該外掛能夠從您的分類永久連結中移除父級分類 (可選)。, 該外掛能夠將標籤基礎從...。
Simple Post Type Permalinks 》輕鬆編輯自訂文章類型的永久網址結構。, 簡單文章類型永久連結比自訂文章類型永久連結更簡單而聰明。, 可用的標籤包括%post_id%,%postname%,%year%,%month...。
Remove CPT base 》從網址中移除自訂文章類型基本標誌, , 可以選擇特定的自訂文章類型, 自動重新導向舊的基本標誌到無基礎標誌, 。
WP htaccess Control 》WP htaccess Control(也可以稱為 WP htaccess 和 Rewrite Control)提供了一個界面來自定生成WordPress的htaccess文件以及其永久鏈接(作者、分類、歸檔、分...。
Admin Slug Column 》這個外掛會在「所有文章」和「所有頁面」的 wp-admin 界面上新增一欄,顯示每一個文章或頁面的 URL 路徑和別名。如果某個頁面是某個父頁面的子頁面,也會顯示...。
Top Level Categories 》這個「Top Level Categories」外掛可以讓您移除類別頁面 URL 前面的字首。例如,您可以使用 http://fortes.com/work 代替 http://fortes.com/category/work ...。
Permalinks Customizer 》自定義永久網址助手(Permalinks Customizer)可為公開訪問的不同文章類型和分類定義不同的永久網址結構。您可以使用 WordPress 中已定義的標籤,如此處所述...。
WP Permalink Translator 》允許管理員將永久連結翻譯成其他語言。, 開發, https://github.com/hossinasaadi/wp-permalink-translator/。
WP Category Permalink 》這個外掛讓你可以為你的文章選擇一個主要分類或分類法以便得到更好的永久連結和SEO效果。, 功能, 通常,你會選擇自訂結構 /%category%/%postname%/% 作為永久...。
Simple Slug Translate 》Simple Slug Translate 可以自動將文章、頁面、分類和分類法名稱翻譯成英文。, 它可以讓永久連結更好看,同時也對SEO有好處。, 翻譯引擎由Watson Language Tr...。
Custom Permalink Editor 》, 這個外掛是由 Team KCG 開發,用來更改文章、頁面和自訂文章的 URL。, 這個外掛允許您編輯文章、頁面和自訂文章的永久連結。, 這個外掛不會更改佈景主題預...。