外掛說明
如果想要控制 WordPress 網站的網址,Custom Permalinks 能讓網站管理員為任何文章、頁面、標籤或分類自訂唯一網址。這代表網站管理員可以依據需求設定網站結構,而不會受到 WordPress 預設設定的限制。網站管理員設定自訂永久連結後,內容的原始連結會自動重新導向至新的自訂網址。
主要功能
- 個別永久連結控制:為文章、頁面標籤或分類指派唯一的網址。
- 網站結構控制:獲得網站網址的完整控制權。
- 內容類型永久連結結構 (3.0.0 或更新版本):使用預先定義的標籤為公開的內容類型設定自訂永久連結結構,並在建立內容時自動產生網址,但使用者仍可手動編輯永久連結。如果不進行設定,則會套用預設設定。
- Automatic Redirects: Old URLs keep working — visitors and search engines are redirected to the new custom permalink automatically.
開始使用:外掛設定
網站管理員可以前往 WordPress 控制台的 [設定]→[Custom Permalinks] 設定自訂永久連結。
To set a permalink for an individual post, page, category, or tag, edit that item and look for the Custom Permalink field near the top (or in the sidebar) of the editor screen — enter the URL path you want and save.
可用於永久連結結構的標籤
設定網站的自訂永久連結時,網站管理員可以使用多種標籤在網址中動態填入對應的值。以下是可供使用的標籤:
- %year%:內容的 4 位數發佈年份,例如 1972。
- %monthnum%:內容的 2 位數發佈月份,例如 11。
- %day%:內容的 2 位數發佈日期,例如 14。
- %hour%:內容的 2 位數發佈時間小時,例如 15。
- %minute%:內容的 2 位數發佈時間分鐘,例如 43。
- %second%:內容的 2 位數發佈時間秒數,例如 33。
- %post_id%:內容的唯一 ID,例如 1114。
- %category%:分類名稱的代稱,巢狀子分類在網址中會顯示為巢狀目錄。
- %author%:內容作者名稱經過清理的版本。
- %postname%:內容標題的簡易版本,也就是該篇內容的代稱。舉例如說,如果內容標題為「This Is A Great Post!」,在網址中就會是
this-is-a-great-post。 - %parent_postname%:類似
%postname%,但如果選取上層頁面,則會使用上層頁面的代稱。 - %parents_postnames%:類似
%postname%,但如果選取多個上層頁面,則會使用全部上層頁面的代稱。 - %title%:將內容標題直接轉換為代稱。舉例來說,如果內容標題為「This Is A Great Post!」,在網址中就會是
this-is-a-great-post。與%postname%只會設定一次不同,除非內容已發佈或手動編輯永久連結,否則如果變更內容標題,%title%便會在永久連結中自動更新。 - %ctax_TAXONOMY_NAME%:自訂分類法名稱的簡易版本,使用自訂分類法的實際名稱取代
TAXONOMY_NAME。網站管理員可以使用??為沒有設定分類/分類法的內容設定預設代稱。舉例來說,使用%ctax_type??sales%就代表將 sales 設定為預設代稱。 - %ctax_TAXONOMY_NAME_name%: The custom taxonomy term’s name (instead of its slug). Replace
TAXONOMY_NAMEwith the actual taxonomy name. Supports a default value using??when no term is selected (e.g.,%ctax_type_name??Sales%). - %ctax_parent_TAXONOMY_NAME%:類似
%ctax_TAXONOMY_NAME%,但如果選取上層項目,則網址會包含上層項目的代稱。 - %ctax_parent_TAXONOMY_NAME_name%: Similar to
%ctax_TAXONOMY_NAME_name%, but includes the immediate parent term’s name if a parent is selected. - %ctax_parents_TAXONOMY_NAME%:類似
%ctax_TAXONOMY_NAME%,但如果選取多個上層項目,則網址會包含全部上層項目的代稱。 - %ctax_parents_TAXONOMY_NAME_name%: Similar to
%ctax_TAXONOMY_NAME_name%, but includes all parent term names if parents are selected. - %custom_permalinks_TAG_NAME%:開發者可以擁有自訂專屬標籤 (將
_TAG_NAME取代為想要的名稱) 的彈性,要確保這些標籤可以解析為正確的永久連結,只要套用custom_permalinks_post_permalink_tag篩選器即可。
重要通注意事項:在 Custom Permalinks 設定中完成結構定義後,針對撰寫的新內容,外掛在內容為草稿時會持續更新永久連結。內容發佈後或手動更新其永久連結,外掛會對這類內容停止自動更新。
Custom Permalinks:篩選器微調
Custom Permalinks 提供一系列讓開發者可以精準控制行為的篩選器,請前往這個外掛的 GitHub 存放庫查看全部可供使用的篩選器及完整的程式碼片段範例。
取得協助
- 付費使用者:如果在實作這些篩選器時需要協助,請透過付費使用者技術支援聯絡表單直接與我們聯絡。
- 其他使用者:請透過 LinkedIn 直接聯絡外掛開發者。
需要協助或找到程式碼錯誤?
- 技術支援:如需一對一電子郵件技術支援,請考慮購買 Custom Permalinks 付費方案。在 WordPress.org 技術支援論壇僅提供基本技術支援,電子郵件技術支援僅供付費方案使用者使用。
- 回報程式碼錯誤:如果在使用上遇到程式碼錯誤,請前往 GitHub 存放庫回報,並請務必提供可重現問題的完整資訊。GitHub 存放庫僅供回報程式碼錯誤,不提供技術支援。
如果外掛更新後造成網站停擺,請在技術支援論壇回報,或前往 GitHub 存放庫提供詳細資訊。如果需要還原為舊版外掛,請前往這個外掛的 [進階檢視] 下載。
安裝方式
安裝 Custom Permalinks 有 2 種方式:
自動安裝
- 前往 WordPress 控制台的 [外掛]→[安裝外掛]。
- 搜尋「Custom Permalinks」。
- 在 [外掛] 頁面中點擊 [立即安裝] 後然後點擊 [啟用]。
透過 FTP 手動安裝
- 下載
custom-permalinks資料夾。 - 將外掛安裝套件 ZIP 壓縮檔解壓縮所得的
custom-permalinks資料夾上傳至網站的/wp-content/plugins/目錄。 - 透過 WordPress 管理後台的 [外掛] 選單啟用 Custom Permalinks。
常見問題集
-
What happens to the original URL when I set a custom permalink?
-
Custom Permalinks automatically redirects the original (default) URL to your new custom permalink, so existing links, bookmarks, and search engine rankings keep working.
-
Will this affect my site’s SEO?
-
It shouldn’t hurt it — since the original URL redirects to the new one, search engines and existing backlinks continue to resolve correctly. Using clean, descriptive custom permalinks can also make your URLs more readable, which is generally good for SEO.
-
Yes. Custom Permalinks supports posts, pages, any public custom post type, and categories/tags (and other custom taxonomy terms).
-
Does it work with custom post types, like WooCommerce products?
-
Yes. You can set an individual custom permalink on any public custom post type, or define an automatic permalink structure for the entire post type from Settings > Custom Permalinks.
-
Is Custom Permalinks compatible with WPML or Polylang?
-
Yes, the plugin is compatible with both WPML and Polylang, including translated posts that each have their own custom permalink.
-
Can I let a non-administrator manage permalinks?
-
Yes. The plugin adds a dedicated Custom Permalinks Manager role (and matching capabilities) so you can let specific non-admin users view or edit permalinks without giving them full administrator access.
-
Can I use accented letters, uppercase letters, or extra hyphens in my permalinks?
-
By default, Custom Permalinks sanitizes permalinks the same way WordPress core does (lowercase, no accents, no repeated hyphens). Developers can lift these restrictions with the
custom_permalinks_allow_accents,custom_permalinks_allow_caps, andcustom_permalinks_redundant_hyphensfilters. See the Advanced Customization and Filters section on GitHub. -
A page builder’s front-end preview (Cornerstone, etc.) breaks or loses its editing mode on pages with a custom permalink
-
Some page builders load their live/front-end preview in an iframe using a
POSTrequest carrying special values the builder needs (for example Cornerstone’scs_preview_time). If that page also has a custom permalink, Custom Permalinks may redirect the request, and since redirects are followed asGET, the builder’sPOSTdata is lost and the preview breaks.You can tell Custom Permalinks to skip its redirect for that request with the
custom_permalinks_avoid_redirectfilter, added to your theme or a site-specific plugin:add_filter( 'custom_permalinks_avoid_redirect', function( $permalink ) { if ( isset( $_POST['cs_preview_time'] ) ) { // Adjust to match the field your builder sends. return true; } return false; } );See the Advanced Customization and Filters section on GitHub for this and other available filters.
-
What happens to my custom permalinks if I deactivate or uninstall the plugin?
-
Deactivating the plugin keeps all your saved custom permalinks in the database — reactivating it restores them immediately. Uninstalling (deleting) the plugin permanently removes all saved custom permalinks and plugin settings, and your URLs will revert to WordPress’ default permalink structure.
-
My custom permalink isn’t saving, or the page isn’t redirecting — what should I check?
-
- Make sure Settings > Permalinks isn’t set to “Plain”.
- Confirm no other SEO/redirection plugin (Yoast, RankMath, Redirection, etc.) has a conflicting rule for the same URL.
- Check that the permalink isn’t already used by another post — Custom Permalinks won’t apply a duplicate URL.
- Still stuck? See “Need Help or Found a Bug?” above, or reach out via GitHub or Premium support.
使用者評論
參與者及開發者
變更記錄
3.2.0 – Aug 20, 2026
Permalink Generation:
* Added support for name-based custom taxonomy permalink tags:
* %ctax_TAXONOMY_NAME_name%
* %ctax_parent_TAXONOMY_NAME_name%
* %ctax_parents_TAXONOMY_NAME_name%
* Use multiple custom taxonomies tags at the same time in permalink
* Updated documentation to describe the new tags and clarify the difference between slug-based and name-based taxonomy tags.
- Bug:
- Fixed a PHP warning (“Attempt to read property ‘term_id’ on null”) on tag/category archive pages in some setups. PR #138
- Fixed an “Undefined array key
_custom_permalinks_term_nonce“ warning when saving a category or tag without touching its Custom Permalink field. - Fixed the auto-generated slug silently failing to save on posts that didn’t yet have a
post_name, when a permalink structure was set to auto-generate permalinks. PR #148 - Fixed
%parent_postname%and%parents_postnames%silently dropping the post’s own slug from the generated permalink when used without also including%postname%in the structure. PR #149 - Fixed WPML internal links pointing to the original page instead of the translated page’s own custom permalink (e.g. links created with the Gutenberg link tool).
- Fixed custom permalinks getting overwritten with another product’s permalink when bulk editing multiple products/posts in a single request.
- Fixed the language directory getting duplicated (e.g.
/de/de/your-slug/) in permalinks generated for WPML directory-based language negotiation, and hardened the WPML permalink filter against a non-string return value that could corrupt the REST API’s JSON response when saving a post from the Block Editor. - Fixed a stale permalink cache entry for permalinks with a trailing slash, which could cause a newly saved custom permalink to 404 until the cache expired. PR #153
- Fixed translated pages resolving to the wrong language’s post (wrong-language redirects, 404s on a translation, editor opening the wrong translation) when two WPML/Polylang translations shared the same custom permalink outside of “different domain per language” mode.
- Fixed WooCommerce My Account endpoints (e.g. edit-address, edit-account) redirecting back to the base My Account page instead of loading, when the My Account page has a custom permalink set.
- Fixed emptying the Custom Permalink field and saving not removing the saved permalink.
- Fixed a request that only differed from the saved permalink by a trailing slash failing to resolve — it now redirects to the canonical permalink instead.
- Fixed the trailing-slash redirect ignoring the
custom_permalinks_avoid_redirectfilter, which could still break page builders’ front-end preview iframes (e.g. Cornerstone) after applying the documented workaround.
3.1.2 – Sep 24, 2025
3.1.1 – Sep 19, 2025
- Bugs:
3.1.0 – Aug 01, 2025
Permalink Generation:
- Resolved an issue where the
custom_permalinks_generate_post_permalinkfunction was creating duplicate permalinks with appended numbers when triggered programmatically. This ensures a unique, clean URL every time. - Updated the
sanitize_text_fieldfunction to prevent the truncation of permalink tags, such as%category%and%day%, guaranteeing your custom permalink structure remains intact.
Performance:
- The
save_posthook will now only run on public post types. This change prevents unnecessary processing on post types like “Menus”, which can significantly improve performance on sites with complex configurations.
Maintenance:
- Improved internationalization (I18N) support.
- Fixed a bug where the cache group was not properly clearing when using the flush button.
Language:
- Updated the plugin with the latest language packs.
3.0.1 – Jul 22, 2025
Fix PHP warning on url_to_postid() filter.
3.0.0 – Jul 22, 2025
This release of Custom Permalinks brings significant enhancements to post type permalink management, introduces new customization options, and refines the overall user and developer experience.
Added
- Post Type Permalink Structures: Introduced robust functionality to define custom permalink structures for each public Post Type directly within the plugin settings. This allows for automatic URL generation based on predefined tags upon content creation, offering greater flexibility while still allowing manual edits.
- New Available Permalink Tags: Expanded the list of dynamic tags that can be used in permalink structures, including:
%parent_postname%: For immediate parent page slugs.%parents_postnames%: For all parent page slugs.%title%: A dynamic slug that updates with post title changes (until published or manually edited).%ctax_parent_TAXONOMY_NAME%: For immediate parent custom taxonomy slugs.%ctax_parents_TAXONOMY_NAME%: For all parent custom taxonomy slugs.%custom_permalinks_TAG_NAME%: Allows developers to define and resolve their own custom tags.
- WP All Import Compatibility: Added support to generate/update permalinks when importing posts using the WP All Import plugin.
- New Filter Examples: Included clear code examples for
custom_permalinks_post_permalink_tagto set custom values from ACF fields, and for programmatically generating permalinks for single posts and entire post types.
Improved
- Post Caching: Enhanced post caching mechanisms and optimized cache deletion upon updates for better performance.
- Permalink Retrieval: Improved logic to allow fetching posts against customized permalinks.
- Filter Documentation: Refined existing filter descriptions and improved code formatting for clarity.
- Plugin Purpose Clarity: Updated documentation to explicitly state that original post URLs will automatically redirect to the customized URLs, ensuring seamless transitions.
Earlier versions
- For the changelog of earlier versions, please refer to the separate changelog.txt file.
