How to Fix WordPress Custom Post Type 404 Errors & URL Conflicts

In WordPress, each custom post type uses a unique permalink structure. This structure is determined by the "rewrite slug", which helps WordPress figure out what content to show when a user visits a particular URL.

In most situations, the rewrite slug is automatically set to match the custom post type name. While you can modify it, doing so improperly may cause issues, such as broken links or inaccessible pages. The most common mistake is using the same slug for multiple post types or setting it to "/".

This guide will show you how to avoid these problems and keep your custom post types working as expected.

The rewrite rules array is a list of patterns used to recognize and handle URLs. When a user visits a URL, WordPress checks it against these rules and identifies which content to display by pulling a slug from the URL.

They are based on regular expressions that match parts of a URL to specific content. To make it clearer, consider the rule used for URLs of built-in posts and pages:

^/([^/]+)/?$

This rule tells WordPress to match any URL with the flat pattern, e.g.:

https://example.com/%POSTNAME%/
https://example.com/hello-world/

and retrieve the post that matches the title in the URL. To sum up, these rules act like a map, guiding WordPress to the relevant post, page, or custom post type item.

A sample rewrite rule in action

Sometimes, depending on your website’s configuration, different content types might follow the same URL pattern. In these cases, the rule that appears first in the rewrite rules list will take precedence and be applied.

What is a Rewrite Slug and How to Change It?

When you register a custom post type or taxonomy in WordPress, the rewrite slug is the part of the URL that comes before the individual post or term name. It works as a URL‑friendly identifier that lets WordPress distinguish one custom post type or taxonomy from another.

This value can be set in the rewrite argument when you register the content type.

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' );

If you use ACF to register custom post types, you can set the rewrite slug directly from the UI.

  1. Go to "ACF -> Post Types", open the post type you want to edit, and enable "Advanced Configuration".
  2. Under the URLs tab, set Permalink Rewrite to "Custom Permalink" and enter your new slug in the "URL Slug" field.

ACF rewrite slug settings

For example, if your custom post type is named "Book" and you override the rewrite slug to publication , the sample permalink will look like:

https://example.com/publication/a-sample-cpt-permalink

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

Common Symptoms of URL Conflicts

While this kind of rewrite conflict is possible with any custom post type, it is particularly common with WooCommerce products. A typical scenario involves changing the product URL structure by removing the /product/ base, which then leads to unexpected 404 errors throughout the website.

WooCommerce default settings

This issue often goes unnoticed because WordPress does not show any error messages or alerts when it occurs. Even experienced developers may trigger this unintentionally, when attempting to remove the custom post type rewrite slug by setting it as a single forward slash ('/').

...
'rewrite' => array( 'slug' => '/' ),
...

This seems logical at first glance, though it will not behave as intended. Unfortunately, making it like this will overwrite the other rewrite rules and could cause unexpected problems, such as broken links and missing content.

This limitation is due to how WordPress handles permalinks. While this built-in system work good enough for most typical cases, it does not allow the same format to be shared across different content types.

When there is no rewrite slug for a CPT, WordPress can handle the situation in two ways, depending on the rewrite slug's priority. Either scenario will make some of your content unavailable.

  1. It could end up treating pages and posts as custom post type items, leading to 404 errors.
  2. Alternatively, it may ignore the custom post type's rewrite rules, causing the custom post type items to show 404 errors.

4 Proven Ways to Fix Custom Post Type URL Conflicts

Most 404 errors are related to rewrite rule conflicts or an outdated rewrite rules array, but this is not the only possible cause.

In most cases, you can resolve this issue quickly by following the steps below.

Flush the Rewrite Rules

If your site shows 404 errors after updating the permalinks, the cause is often cached rewrite rules. In WordPress, these rules are stored in the database and they do not always refresh automatically when permalink settings change.

Before making any additional changes, try flushing the rewrite rules. To flush them, open "Settings -> Permalinks" in the admin panel and click "Save Changes" while leaving all options as they are.

If the 404 errors go away after this step, no further action is needed. If not, follow the additional troubleshooting steps below.

Set a Unique Slug for Each Post Type and Taxonomy

URL conflicts usually occur when multiple content types share the same permalink base. When you register a custom post type or taxonomy, make sure the rewrite slug is unique.

In most cases you do not need to change anything, since WordPress automatically uses the post type name as the default rewrite slug. Adjust it only if you want a custom permalink structure.

If you need more control over your site’s permalink structure, consider using a dedicated permalink plugin. Permalink Manager is often used to resolve URL conflicts, especially when different post types or taxonomies must share the same permalink base.

You can use it remove the permalink base from custom post types and taxonomies or duplicate rewrite slugs, which is not supported by the native permalink system.

Permalink Manager handles URLs changes automatically. When a permalink is updated, it uses canonical redirect to send visitors from the old URL to the new one. This keeps your existing links intact and prevents 404 errors, without any manual redirect setup.

Remove rewrite slug from custom post types' permalinks

Duplicate rewrite slugs

Use a Code Snippet to Remove CPT Slugs

If you prefer not to install a plugin, a code snippet can remove the rewrite base from custom post type URLs without breaking existing rewrite rules.

The code below allows WordPress recognize post types directly from the URL using the post slug, without relying on rewrite rules.

  1. The first function looks through posts, pages, and any specified custom post types to identify a matching slug.
  2. The second function rewrites the custom post type permalink by stripping the original base. It uses the native post_type_link filter, which is intended for customizing single CPT permalinks.
The simplest way to make this code work is to add the code snippet directly to your theme's functions.php file.
function pm_get_custom_post_types() {
	return array( 'cpt_1', 'cpt_2' );
}
function pm_rewrite_cpt_permalinks( $post_link, $post, $leavename, $sample ) {
	$custom_post_types = pm_get_custom_post_types();
	if ( ! empty( $post->post_type ) && in_array( $post->post_type, $custom_post_types ) ) {
		if ( $leavename ) {
			$post_link = home_url( "%{$post->post_type}%" );
		} else {
			$post_link = home_url( $post->post_name );
		}
		$post_link = user_trailingslashit( $post_link );
	}
	return $post_link;
}
add_filter( 'post_type_link', 'pm_rewrite_cpt_permalinks', 10, 4 );
function pm_parse_cpt_permalinks( $query ) {
	if ( ! $query->is_main_query() || 2 != count( $query->query ) || ! isset( $query->query['page'] ) ) {
		return;
	}
	if ( ! empty( $query->query['name'] ) ) {
		$query->set( 'post_type', array_merge( array( 'post', 'page' ), pm_get_custom_post_types() ) );
	}
}
add_action( 'pre_get_posts', 'pm_parse_cpt_permalinks' );

Permalinks can be tricky to manage, so this snippet might not work in every scenario. Other plugins or custom rules could change how permalinks are processed. Feel free to tweak it based on your WordPress setup.

FAQ & Troubleshooting

Seeing a "Page Not Found" error after updating URLs is a common issue. This usually happens for a few common reasons.

  1. Server permissions:
    The .htaccess file (Apache) file needs to update when you change the permalink settings and flush rewrite rules. If WordPress does not have the right permissions to write new rules to those config files, the new settings will not take effect.
  2. Missing redirects:
    WordPress does not automatically create redirects when permalinks are changed, so when a visitor clicks an old link, the server looks for a page that is no longer there.
  3. Outdated cache:
    Your site might be serving stale URLs from page cache, object cache, CDN, or browser cache. Clearing all active caches is usually a good first troubleshooting step.
  4. Rewrite rule conflicts:
    Using the same permalink structure for custom post types and taxonomies can lead to URL conflicts. When two rules match the same URL structure, WordPress cannot determine which content item to display.

Why Bricks & Elementor Fail Due to URL Conflicts?

Rewrite rule conflicts can also be caused by third-party plugins. These conflicts can affect both WordPress itself and other plugins.

For example, using the same permalink structure for multiple content types, or removing the rewrite slug from a custom post type, can stop editors like Bricks or Elementor from working correctly.

When this happens, editors like Bricks and Elementor can get stuck during loading, showing messages like "Invalid post type" or "The preview could not be loaded".

Last updated by Maciej Bis on: February 22, 2026.


Maciej BisFounder of Permalink Manager & WordPress Developer

The developer behind Permalink Manager, a plugin for managing permalinks, has been working with WordPress, creating custom plugins and themes, for more than a decade.

Leave a Reply

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