Custom Post Type Permalinks

It is no surprise that WordPress does not provide much control over custom post type permalinks. Thankfully, there are tools like plugins that may help with this and maximize their SEO potential.

When working with custom post types and configuring their permalinks, you should pay attention to the "rewrite" slug, which determines how these permalinks are formatted.

In this article, you will learn how to control it using the built-in settings and how Permalink Manager can help you optimize custom post type permalinks if you require a more advanced and tailored permalink structure.

What are Custom Post Types?

The basic content types included with WordPress are pages and posts. WordPress includes two default content types: posts and pages. Sometimes the data does not fit into either of the built-in content types. If this is the case, you may declare a custom content types and separate the content from the standard posts and pages.

There are many situations when this may be useful. Custom post types may handle a variety of content types, including testimonials and events. They are also an essential component of the WooCommerce plugin, which uses them for products.

Declaring Custom Post Types

There are many methods to define a custom post type. The simplest way is to add a code snippet to your WordPress codebase. It is not that difficult, and you need to use the register_post_type() function.

function custom_post_type_registration() {
	 $args = array(
		 'public' => true,
		 'label' => 'Book',
		 'supports' => array('title', 'editor', 'thumbnail'),
		 'rewrite' => array('slug' => 'publication'),
	 );
	 register_post_type('book', $args);
}
add_action('init', 'custom_post_type_registration');

There is a more convenient way if you are not good at coding and do not mind installing another plugin! You can use one of the many ready-made plugins available.

To name a few, "ACF", "Toolset", "Custom Post Type UI", and "Pods" are among the most popular. They all have user-friendly interfaces that allow you to define new content types without writing any additional code.

Not declaring the 'rewrite' arguments causes WordPress to use the custom post type's slug name, which in this case is "book".

Custom Post Type Permalinks

One of the parameters you can pass to the register_post_type() function is the rewrite slug. To put it simply, it defines the basic structure of the custom post type's permalink.

When setting up the custom post types, users often overlook it. Understanding this is critical in order to avoid rewrite rules conflicts that might prevent WordPress from processing URLs correctly.

To make things clear, let us go back to the basic code from the previous section. The rewrite slug is specified as the 'slug' parameter under 'rewrite'. In that particular instance, it is set to 'publication'. Therefore, the custom post type's permalink structure will be as follows:

https://example.com/publication/post-title

Many developers try to remove the rewrite slug from custom post type permalinks by changing it to single slash "/", hence breaking the permalinks structure and causing unexpected "404 Not Found" errors.

Configuring Rewrite Slugs in ACF

One of the most well-known WordPress plugins is Advanced Custom Fields (ACF). When setting up custom post types with ACF, you can easily set the rewrite slug within the plugin interface.

To access the "URL Slug" field, first turn on the "Advanced Configuration" toggle button. After enabling it, go to the "Permalink Rewrite" section and select the "Custom Permalink" option.

ACF permalink settings

What Is the Problem With the Default Custom Post Type Permalinks?

There are some problems that can come up with WordPress's default custom post type permalinks. They mostly have to do with URL structure and how it affects user experience and SEO.

Simply put, WordPress includes the rewrite slug as part of the URL structure. This can result in non-descriptive and lengthy URLs that are not user-friendly or optimized for search engines.

Rewrite slug in custom post type permalink
By default, you can only use the slug (anna-nowak), which is the last part of the URL. Rewrite slug "/team/" in the example above cannot be easily customized.

The default settings may not provide users with enough control over the structure of their custom post type permalinks. This is apparent if you want to use the same permalink format for more than one type of content.

Duplicate rewrite base in WordPress permalinks

There are situations when you may need more flexibility, such as reusing the same URL structure for multiple custom post types. In such a situation, WordPress's default settings might not be enough and then you have two options available.

If you know PHP, you may write a tailored code snippet or pay a WordPress developer to do it for you. You can also use an already-made solution, like the Permalink Manager plugin, which will save you time and money.

By using a tool like Permalink Manager, developers may adjust the URL structure for each custom post type without worrying about rewrite rules conflicts. This plugin provides a user-friendly interface for managing permalinks, offering a level of control that might be difficult to achieve with a code snippet.

One of the most useful and popular features of Permalink Manager Pro is the ability to edit individual permalinks within custom post types. This allows you to customize the URL structure of each post to meet specific SEO and readability requirements.

Edit individual custom post type permalink

The plugin lets you change each URL as a whole, unlike the WordPress permalink system, which only allows changes to the last slug.

Custom Fields in Custom Post Type Permalinks

Another feature not found in other tools is the ability to dynamically add custom fields to custom permalinks. Custom fields are extra pieces of information associated with a post, and incorporating them into permalinks may improve both SEO and UX.

Add custom fields to permalinks

This feature is especially helpful if you want to include dynamic content directly in the URL, like location, SKU number, etc.

Taxonomies are just as important for organizing content on your WordPress website as custom post types. Because taxonomies are connected to post types, you can use the Permalink Manager to easily add the linked taxonomy terms in the post type permalinks.

Edit individual custom post type permalink

By doing so, you can build a hierarchical URL structure that better depicts the connections between your content elements. It is a good starting point for SEO and improving the usability of your website.

FAQ

What Is the Simplest Way to Customize the Custom Post Types URLs?

Absolutely! There is always a solution available, whether you are a coding expert or a WordPress beginner. One of the most convenient and user-friendly solutions is using a plugin like "Permalink Manager". It allows you to configure custom post type permalinks without writing any code.

Can I Register a Custom Post Type Without Using PHP Code?

If you are not familiar with coding or are unsure how to write your own code snippet, a plugin is the most reliable option. There are lots of plugins you can use, like "Pods" or "ACF", that let you define additional custom fields. You can install them for free directly from admin dashboard.

Avatar for Maciej BisAbout Maciej Bis

Maciej has over 10 years of WordPress expertise and is the author of Permalink Manager, a popular WordPress plugin for managing permalinks. He has extensive experience in WordPress programming and has worked with clients from all around the world.

Leave a Reply

Your email address will not be published. Required fields are marked *