How to Customize Permalinks with Custom Post Type UI and Taxonomy Slugs
Content
Many WordPress users turn to the Custom Post Type UI plugin to create custom content structures. A frequent goal is to have detailed, SEO-friendly permalinks that include taxonomy terms, such as example.com/services/plumbing/faucet-repair. However, users often discover that achieving this specific URL structure is not a built-in feature of the plugin. This article explains why this happens and outlines the most common solutions available.
The Core Limitation
The Custom Post Type UI plugin is designed for one primary purpose: to reliably register post types and taxonomies in WordPress. It excels at creating the foundation for your custom content. However, it does not handle advanced permalink customization. The plugin's settings allow you to define the base slug for a post type (e.g., services) or a taxonomy (e.g., service_category), but it cannot automatically inject dynamic taxonomy terms into a post's permalink structure.
When you try to use a tag like %taxonomy% in the "Custom Rewrite Slug" field for a post type, it is treated as a literal string. This results in URLs like example.com/services/%service_category%/my-post instead of the desired example.com/services/plumbing/my-post. This is the expected behavior, as transforming those tags into dynamic values requires additional code that falls outside the plugin's scope.
Recommended Solution: Use a Permalink Plugin
The most straightforward method for most users is to employ a dedicated permalink management plugin. These tools are built specifically for complex URL rewriting and often provide a user interface to achieve your desired structure without writing code.
Based on frequent recommendations in the support threads, one of the most popular and effective plugins for this task is Permalink Manager. It allows you to set custom permalink structures that incorporate taxonomy terms, custom fields, and other elements for both posts and taxonomies themselves.
Alternative Solution: Custom Code
For developers comfortable with code, it is possible to modify the permalink structure manually by adding filters to your theme's functions.php file or a custom plugin. This typically involves two main steps:
- Modifying the Post Permalink Structure: Using the
post_type_linkfilter to replace any placeholder tags (like%taxonomy_slug%) in the URL with the actual term slug from the post. - Updating Rewrite Rules: Adding new rewrite rules so that WordPress understands how to interpret the new URL pattern and query for the correct post.
This approach requires a good understanding of WordPress's rewrite API and can be fragile if not implemented correctly, especially after permalink flushes. Numerous tutorials on third-party development blogs detail this process, which can be found by searching for terms like "add taxonomy term to custom post permalinks."
Important Considerations and Common Issues
- Hierarchical Taxonomy Terms: Including multiple levels of a hierarchical taxonomy (e.g.,
domain.com/country/city/post-name) adds another layer of complexity to the rewrite rules and is often best handled by a dedicated plugin. - Taxonomy Archive Links: Changing the post permalink structure does not automatically change the taxonomy term archive URLs. These are controlled by the taxonomy's own rewrite slug setting in CPTUI.
- The "Exclude from Search" Setting: A crucial note from the threads: if you set a custom post type to "Exclude from Search," WordPress will also remove its posts from taxonomy term archives. The recommended workaround is to leave this setting off and use the
pre_get_postsfilter to manually exclude the post type from search results.
In summary, while Custom Post Type UI creates the content structure, achieving complex permalinks requires an additional tool. For most users, a permalink manager plugin is the safest and most efficient path to success.
Related Support Threads Support
-
Custom rewrite slug break permalinks to taxonomy archivehttps://wordpress.org/support/topic/custom-rewrite-slug-break-permalinks-to-taxonomy-archive/
-
Custom Post Type and Taxonomy – permalink to include the taxonomy in the URL?https://wordpress.org/support/topic/custom-post-type-and-taxonomy-permalink-to-include-the-taxonomy-in-the-url/
-
Custom rewritehttps://wordpress.org/support/topic/custom-rewrite-2/
-
Taxation urlhttps://wordpress.org/support/topic/taxation-url/
-
how to not rewrite custom post type url and make taxonomies stayhttps://wordpress.org/support/topic/how-to-not-rewrite-custom-post-type-url-and-make-taxonomies-stay/
-
Adding post type slug before taxonomy slughttps://wordpress.org/support/topic/adding-post-type-slug-before-taxonomy-slug/
-
Exclude custom post type from search but keep custom taxonomy functionalhttps://wordpress.org/support/topic/exclude-custom-post-type-from-search-but-keep-custom-taxonomy-functional/
-
Permalink Issue CPT / Taxonomiehttps://wordpress.org/support/topic/permalink-issue-cpt-taxonomie/
-
Taxonomy Archive Pagehttps://wordpress.org/support/topic/taxonomy-archive-page/
-
Hierarchical Taxonomy URL with Post Typehttps://wordpress.org/support/topic/hierarchical-taxonomy-url-with-post-type/
-
How to manage slugs with Custom Post Type and Taxonomies?https://wordpress.org/support/topic/how-to-manage-slugs-with-custom-post-type-and-taxonomies/
-
Rewrite URL of Taxonomy & SEOhttps://wordpress.org/support/topic/rewrite-url-of-taxonomy-seo/
-
Taxonomy url setting problemhttps://wordpress.org/support/topic/taxonomy-url-setting-problem/
-
Breadcrumbs path not completehttps://wordpress.org/support/topic/breadcrumbs-path-not-complete/
-
Subtaxonomy not working after deleting parent slughttps://wordpress.org/support/topic/subtaxonomy-not-working-after-deleting-parent-slug/
-
Simple URLs including taxonomieshttps://wordpress.org/support/topic/simple-urls-including-taxonomies/
-
Custom post type slug not showing in category urlhttps://wordpress.org/support/topic/custom-post-type-slug-not-showing-in-category-url/
-
Category in urlhttps://wordpress.org/support/topic/category-in-url-2/
-
Use custom taxonomy in slughttps://wordpress.org/support/topic/use-custom-taxonomy-in-slug/
-
Add taxonomy sug to CPT post?https://wordpress.org/support/topic/add-taxonomy-sug-to-cpt-post/
-
Custom category slug in custom post type URLhttps://wordpress.org/support/topic/custom-category-slug-in-custom-post-type-url/
-
Default slug for taxonomy when post created?https://wordpress.org/support/topic/default-slug-for-taxonomy-when-post-created/
-
Slug taxonomy and custom posthttps://wordpress.org/support/topic/slug-taxonomy-and-custom-post/
-
Changing slug of CPT affecting taxonomyhttps://wordpress.org/support/topic/changing-slug-of-cpt-affecting-taxonomy/
-
Taxonomies as url slug does not workhttps://wordpress.org/support/topic/taxonomies-as-url-slug-does-not-work/
-
How to use tags in slug/permalink?https://wordpress.org/support/topic/how-to-use-tags-in-slug-permalink/
-
Custom Rewrite Slug Errorhttps://wordpress.org/support/topic/custom-rewrite-slug-error/
-
Add custom base in permalinks for CPT posts and archiveshttps://wordpress.org/support/topic/add-custom-base-in-permalinks-for-cpt-posts-and-archives/
-
Custom hierarchical URL for custom post typehttps://wordpress.org/support/topic/custom-hierarchical-url-for-custom-post-type/
-
url structurehttps://wordpress.org/support/topic/url-structure-13/
-
Custom post type and custom taxonomies under same slug?https://wordpress.org/support/topic/custom-post-type-and-custom-taxonomies-under-same-slug/
-
Return a combination of multiple taxonomieshttps://wordpress.org/support/topic/return-a-combination-of-multiple-taxonomies/
-
custom post type and taxonomy in the same url with hierarchical taxonomishttps://wordpress.org/support/topic/custom-post-type-and-taxonomy-in-the-same-url-with-hierarchical-taxonomis/
-
If it’s possible to remove the taxonomy slug from category URLs?https://wordpress.org/support/topic/if-its-possible-to-remove-the-taxonomy-slug-from-category-urls/
-
primary taxonomy isn’t correctly selectedhttps://wordpress.org/support/topic/primary-taxonomy-isnt-correctly-selected/
-
Have taxonomy in slughttps://wordpress.org/support/topic/have-taxonomy-in-slug/
-
Taxonomy Permalink Issue w/ Sub-Catshttps://wordpress.org/support/topic/taxonomy-permalink-issue-w-sub-cats/
-
Problems with urlhttps://wordpress.org/support/topic/problems-with-url-5/
-
Several custom taxonomies for CPT, choose the main for slughttps://wordpress.org/support/topic/several-custom-taxonomies-for-cpt-choose-the-main-for-slug/
-
Rewrite post slug with archive slug and post IDhttps://wordpress.org/support/topic/rewrite-post-slug-with-archive-slug-and-post-id/
-
Hierarchical Slug Structurehttps://wordpress.org/support/topic/hierarchical-slug-structure/
-
Same slug for multiple custom post typeshttps://wordpress.org/support/topic/same-slug-for-multiple-custom-post-types/
-
Rewrite slug for custom post type parent pagehttps://wordpress.org/support/topic/rewrite-slug-for-custom-post-type-parent-page/
-
How to custom the slughttps://wordpress.org/support/topic/how-to-custom-the-slug/
-
Rewrite settings not working?https://wordpress.org/support/topic/rewrite-settings-not-working/
-
Slugswith Parent Categoryhttps://wordpress.org/support/topic/slugswith-parent-category/
-
Rewrite Slug %postname% or tegory% not workhttps://wordpress.org/support/topic/rewrite-slug-postname-or-tegory-not-work/
-
Custom Taxonomy with Blog Post Permalinkhttps://wordpress.org/support/topic/custom-taxonomy-with-blog-post-permalink/
-
Remove Taxonomy Base Slughttps://wordpress.org/support/topic/remove-taxonomy-base-slug-2/
-
Custom URL for new postshttps://wordpress.org/support/topic/custom-url-for-new-posts/
-
Custom Taxonomy Sub-Item Slughttps://wordpress.org/support/topic/custom-taxonomy-sub-item-slug/
-
how can I add %author%/ as the front base to a specific custom post type?https://wordpress.org/support/topic/how-can-i-add-author-as-the-front-base-to-a-specific-custom-post-type/