Melopo
📈
Back to Blog
WordPressDeveloper TipsSEOCPT

WordPress Custom Post Type Slugs: Best Practices

October 15, 2024
6 min read

What Are CPT Slugs and Why Do They Matter?

When you register a Custom Post Type in WordPress, you define a slug — the URL segment that identifies your post type. For example, if your CPT is "Portfolio", the slug might be portfolio, making your URLs look like /portfolio/my-project/.

This slug is one of the most impactful SEO decisions you'll make for a custom post type. Getting it right from the start saves significant refactoring later.

The Anatomy of a CPT Slug

When registering a CPT, the slug is set in the rewrite argument:

``php register_post_type('portfolio', [ 'label' => 'Portfolio', 'rewrite' => [ 'slug' => 'work', // This is your CPT slug 'with_front' => false, ], // ... other args ]); `

Best Practices

#### 1. Choose Semantic, SEO-Friendly Slugs

Your slug should describe the content, not the technical implementation:

BadGood
|-----|------|
/cpt1//products/
/my-portfolio-items//work/
/custom-testimonial-post-type//reviews/

Keep slugs short (1-2 words), lowercase, and hyphenated.

#### 2. Avoid Conflicting Slugs

Never use a slug that conflicts with:

  • Default WordPress pages (/page/, /category/, /tag/)
  • Existing pages in your site
  • Other CPT slugs from other plugins
CPTSM Slug Manager detects these conflicts automatically.

#### 3. Use with_front: false When Appropriate

By default, WordPress prepends your "front" base to CPT URLs. If your permalink structure is /blog/%postname%/, your CPT would become /blog/portfolio/my-project/ unless you set with_front => false`.

For most CPTs, you want clean URLs without the blog prefix.

#### 4. Plan for Multilingual Sites

If you plan to go multilingual, choose slugs that translate well. Some slugs work across languages; others need to be localized. Plugins like WPML require slug translations to be set up at the CPT registration level.

Fixing Existing Slugs

If you need to change a CPT slug on a live site, follow this process:

  • Update the slug in your plugin or theme code (or use CPTSM Slug Manager)
  • Set up 301 redirects from old URLs to new URLs
  • Update your sitemap and resubmit to Google Search Console
  • Update internal links using a plugin like Better Search Replace

Using CPTSM Slug Manager

Instead of editing PHP directly, CPTSM Slug Manager provides a visual dashboard where you can:

  • See all registered CPTs and their current slugs
  • Edit slugs without touching code
  • Get instant conflict detection warnings
  • Preview the URL changes before applying
This is especially useful for agencies managing multiple client sites or developers who need to update slugs without a code deploy.

Conclusion

CPT slugs are a small configuration detail with a big impact on SEO and user experience. Set them up correctly from day one, document your decisions, and use a tool like CPTSM Slug Manager to manage them safely as your site evolves.

More Articles