Remove CPT Base

Custom post types in WordPress have a base slug: /products/blue-widget, /portfolio/project-name. This module removes that base, giving you cleaner URLs: /blue-widget, /project-name.

Use Cases

  • Create cleaner product URLs without /products/
  • Remove /portfolio/ from portfolio item URLs
  • Shorten URLs for better sharing and SEO
  • Match URL structure to site hierarchy

How It Works

The module:

  1. Filters permalink generation to remove the CPT base
  2. Adds rewrite rules so WordPress finds posts at the new URLs
  3. Redirects old URLs (with base) to new URLs (301 redirect)
  4. Flushes permalinks when settings change

Settings

SettingTypeDescription
Post TypesMulti-selectCPTs to remove base slug from

Enabling for a CPT

  1. Open module settings
  2. Select the custom post types
  3. Save settings
  4. Permalinks flush automatically

URL Changes

BeforeAfter
/products/blue-widget//blue-widget/
/portfolio/project-one//project-one/
/services/consulting//consulting/

Conflict Prevention

The module checks for slug conflicts:

  • If a page and CPT item have the same slug, the page takes priority
  • Posts and pages slugs are checked to prevent collisions
  • Warning appears if conflicts are detected

Ensure your CPT item slugs don’t conflict with page, post, or category slugs. Conflicts can cause 404 errors or wrong content serving.

Old URL Handling

When someone visits the old URL (with base):

  1. Module detects the old URL pattern
  2. Performs a 301 permanent redirect to the new URL
  3. Search engines update their index
  4. Bookmarks still work via redirect

SEO Considerations

Benefits:

  • Shorter URLs can improve click-through rates
  • Cleaner URLs look more professional
  • Removes redundant URL segments

Cautions:

  • Changing URLs affects SEO temporarily
  • 301 redirects pass most link equity
  • Allow time for search engines to reindex

Technical Details

The module uses:

  • post_type_link filter to modify permalinks
  • request filter to parse incoming URLs
  • init action to register rewrite rules
  • template_redirect for old URL redirects

Permalinks are flushed automatically when settings change.

FAQ

Will this break existing links?No. Old URLs with the CPT base automatically redirect to new URLs. External links and bookmarks continue working.
What if my CPT slug conflicts with a page?The page takes priority. If you have a page at /consulting/ and a CPT item with slug consulting, the page displays. Rename one to avoid conflicts.
Do I need to update my sitemap?Most SEO plugins automatically detect permalink changes. Regenerate your sitemap or let it update on its own to reflect new URLs.
Can I use this with WooCommerce products?Yes, but test carefully. WooCommerce has complex permalink handling. Ensure product URLs work and don’t conflict with shop pages.
Why do I see a 404 after enabling?Permalinks may need flushing. Go to Settings → Permalinks and click Save (even without changes) to flush rewrite rules.

Before enabling on a live site, test on staging. Map out your CPT slugs and ensure no conflicts with existing pages or posts.

PRO

Get access to all 166 modules with a single license

Upgrade to Pro