Managing url structure for your WordPress website or blog could be tedious especially when you have multiple post types.
Let’s learn this through following example.
Suppose we have 3 types of content in website i.e. Blog posts, services and news. For these, we want to create the following URL structures.
Blog Posts : www.domain.com/blog/[post-slug]
Services : www.domain.com/service/[service-slug]
News : www.domain.com/news/[news-slug]
For custom post types, we will be using the plugin “Custom Post Type UI“
Setting permalink structure for default blog posts
- Go to “Settings” > “Permalinks”
- In “Common Settings”, select “Custom Structure” and input the following value
/blog/%postname%/
- Click on “Save Changes”
Setting permalink structure for custom post types
- Go to “CPT UI” > “Add/Edit Post Types”
- Open “Edit Post Types” tab and select the appropriate post type from the dropdown. In our case, it’s Services post type.
- Scroll down to “Settings” section and find the “Rewrite” field. This should be “True” for wordpress to enable rewrites.
- Update the “Custom Rewrite Slug” to the required path. So, we will update it to “service”.
- Set the “With Front” field to “False”.
If you keep it True, then it will put the default permalink structure at front like www.domain.com/blog/service/[service-slug]. But we don’t want “blog” here.
You can set the custom url structure for other post types as well in the same way.