How to Allow Duplicate Slugs in WordPress & WooCommerce URLs?

WordPress prevents duplicate slugs by automatically adding numeric suffixes or parent titles to your URLs. When you create a second page titled "Contact", WordPress changes its permalink, creating awkward URLs such as "contact-2" or "billing/faq-billing".

The "-2" at the end of your URL isn't a bug. This happens when the same slug is already in use by another post or category and WordPress added it to avoid confusion.

AI-generated code sometimes tries to prevent this by adjusting rewrite rules. This is often not enough, since detecting URLs with duplicated slugs needs changing the $wp_query object directly.

That is exactly what Permalink Manager does. It bypasses the rewrite rules and uses its own URL parser to load the correct page every time, even when the same slug is used more than once.

Example URLs with duplicated slugs

How to Remove "-2" or Parent Title and Reuse the Same Slug

To allow duplicate slugs in the WordPress URLs and remove numeric suffixes like "-2" or parent titles from them, you can choose one of two available solutions.

  1. You can manually remove the numerals appended to the individual permalinks.
  2. You can set Permalink Manager to use post titles instead of the default slugs in custom permalinks.

You can use the plugin to remove "-2" from duplicate slugs in permalinks for posts, pages, categories, and also custom post types and taxonomies.

The easiest way to duplicate the slug is to remove the extra suffix directly in the content editor when changing the permalink. This method works well if you only need to update a few URLs, but it can take longer if your site has many pages using the same slug.

When subcategories have the same name but belong to different parent categories, WordPress adds the parent category slug to their URLs, e.g. ( category/security/faq-security ).

A sample permalink with duplicated slug.By default, the original slug, with extra parent slug added, is also part of the default custom permalink.

Quick Edit Category permalink

To fix it, click into the "Custom permalink" field, delete the extra suffix, and click Update button to save the category.

Quick Edit (After)

New permalink without parent name added to the end of URL.
After: the new custom permalink is now set to category/security/faq .

Instead of adjusting each permalink by hand, you can make the process much faster. To simplify it, enable “Use actual titles as slugs (Force custom slugs)” under "Slugs mode" in the plugin settings.

Use actual titles as slugs

This changes how the plugin generates new custom permalinks for all content types. When enabled, Permalink Manager will always use the actual title (eg. “Shoes“) instead of the native slug (eg. “shoes-2“) in the custom permalink.

By default, the plugin does not automatically update existing permalinks. This is intentional and helps prevent SEO issues or broken links. If you want to apply the new settings to old URLs, you need to regenerate them manually using the "Regenerate/Reset" tool.

If you prefer not to apply this globally, you can adjust the slug mode for selected post types or taxonomies by replacing default tags like %product% or %product_cat% with %native_title%:

Native title

Why WordPress Adds "-2" to Duplicate Slugs

When you publish a post, page, or taxonomy term, WordPress creates a slug from the title. The slug is the part of the URL that identifies the item, for example (for "About us" page):

https://example.com/about-us/

WordPress requires each slug to be unique within the same content type and hierarchy. If a slug is already in use, WordPress handles this inside wp_unique_post_slug() function and adds a number at the end inside, e.g.:

  1. First page titled "About us"about-us
  2. Second page titled "About us"about-us-2
  3. Third page titled "About us"about-us-3

For taxonomy terms (categories, tags, custom taxonomies), WordPress handles this in a different wp_unique_term_slug() function. If a term belongs to a hierarchical taxonomy and the slug already exists, WordPress creates a unique slug by adding the parent term's slug instead of a number.

This can be frustrating when you want to use the same title for multiple child pages or subcategories that belong to different parent items. You may want to use the same slug for e.g.:

  • Hierarchical structures
    Child pages under different parents, for example /marketing/contact/ and /sales/contact/.
  • Multilingual sites
    Similar pages in different languages, such as /en/contact/ and/ /fr/contact/ when using WPML or Polylang.

How WordPress Handles Duplicate Slugs in Categories and Custom Taxonomies

Things work a little differently when you are using hierarchical taxonomies, like product categories in WooCommerce. If you create two categories with the same name under different parent categories, WordPress automatically changes the slug.

Instead of adding a numeric suffix, it includes the parent category’s slug to make each URL unique.

WooCommerce duplicate slugs

Take a look at the example above. WordPress automatically adjusts slugs for subcategories that share the same name, even when they are under different parent categories. Here is how it works:

  1. For your first category, the URL stays clean and exactly as you wanted:
    https://example.com/shop/electronics/laptops/chargers
  2. If you add another "chargers" subcategory under the different parent ("phones"), WordPress adds the parent's title to make the slug unique:
    https://example.com/shop/electronics/phones/chargers-phones
  3. The same happens if you add another "chargers" subcategory under "tablets". WordPress appends the parent slug again:
    https://example.com/shop/electronics/tablets/chargers-tablets

This keeps each URL unique, but it can make permalinks longer. With Permalink Manager, you can reuse the same slug for different subcategories without WordPress adding the parent slug.

Why WordPress Keeps Every Slug Unique

When a visitor goes to e.g. https://example.com/company/about-us/, WordPress processes the request and extracts the slug (about-us). It then uses rewrite rules to see which content type matches this URL and searches the database for a page or term with that slug.

WordPress does not check the full page hierarchy, such as parent page slugs. It looks only at the last slug and stops when it finds the first match.

If you have several pages using the same slug, WordPress could not tell them apart. It would return the same content, based on the first matching page, for all those URLs that uses that slug.

To keep things simple, WordPress needs each slug to be unique. This avoids extra database processing and allows URLs to be parsed with one efficient SQL query.

Can You Remove the "-2" with a Code Snippet?

A snippet can prevent WordPress from adding numbers to slugs, but using the same slug for different posts or pages is a different problem. The real problem is not how the slug is saved, but how WordPress reads the slug back from the URL.

As explained above, WordPress checks the last part of the URL and looks for the first match in the database. Allowing duplicate slugs means bypassing this matching process, which is much more difficult than changing how the slug is saved.

That means writing your own URL-parsing logic and extra handling for edge cases such as hierarchical slugs, multilingual websites, and plugin conflicts.

Permalink Manager handles all of this for you. It checks the full permalink, not only the slug using custom matching algorithm, so different URL can share the same slug without conflicts.

Compared to the built‑in permalink system, Permalink Manager provides more precise control. It uses its own detection logic that checks the full URL rather than only the slug combined with the global permalink structure.

Thanks to this, the plugin can safely handle duplicated slugs and still resolve the correct URLs without generating 404 errors. If you want to review whether all custom permalinks are unique, follow the steps below to identify and fix them.

The plugin includes a soft‑error mechanism that notifies you about duplicate custom permalinks while editing a post or taxonomy term. When the permalink you enter is already in use, a notice is shown below the field.

You can view all detected conflicts in a dedicated section, located in the admin panel under "Tools -> Permalink Manager -> Tools -> Permalink Duplicates".

Duplicated permalink alert in URI Editor

"Permalink Duplicates" section

Permalink Manager includes a built-in functionality to keep your custom URIs unique. You can enable it under "Settings -> Advanced Settings -> Force unique custom permalinks" section.

When enabled, every new custom permalink is checked automatically. If the plugin detects a duplicate, it adds a numeric suffix such as -2 or -3 and keeps increasing the number until the permalink is unique.

Force unique custom permalinks

FAQ & Troubleshooting

How to Fix -2 at End of WordPress URL?

When WordPress adds "-2" to the end of a URL, it means the original slug is already taken. This usually happens when two posts, pages, or custom post types' items use the same title. WordPress adds this number to avoid using the same URL twice.

Common reasons this happens:

  1. Another post or page uses the same slug
  2. A page with the same slug was deleted but still exists in the trash (database)
  3. A translation or draft uses the same URL

With Permalink Manager, you can set the exact URL you want and bypass WordPress slug restrictions. This makes it possible to use clean URLs even when WordPress automatically changes the slug and tries to enforce numbering.

Why Is WordPress Adding a “-2” to the Slug Even Though the Page Doesn’t Exist?

If you try to use a specific slug, such as /services/, but WordPress changes it to /services-2/ even though no other post or page uses that slug, it means the original slug is already "reserved" in the database. This usually happens in one of two cases:

  1. Trashed Pages and Posts
    When you move a post or page to the Trash, WordPress does not delete it immediately from the database. It remains there for 30 days (by default) so you can restore it if needed. Even though it is not "live", the slug (post_name) is still kept in the wp_posts table.
  2. Media Attachments Using the Same Slug
    Every image or file you upload to the Media Library is treated as an attachment (built-in post type) and gets its own entry in the wp_posts table just like posts and pages. To fix it, you must find the image in the Media Library and either change its slug or remove it to "unlock" the slug.

Can I Use the Same Slug Across Different Languages? (Polylang & WPML)

Yes, when using WPML or Polylang, Permalink Manager allows you to use the same permalink slug across different language variants of your content.

For example, if you have an English page with the slug "about-us" and try to create a German version with the same slug, WordPress by default would normally change it to "about-us-2".

Using Permalink Manager, you can set identical slugs for different language versions of the same page or post. This means both your English and German pages can use "about-us" as their slug (with the language-specific URLs handled by your multilingual plugin's URL structure, such as "/en/about-us" and "/de/about-us").

 

Last updated by Maciej Bis on: May 27, 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.

Go up