Change Custom Post Type or CPT Taxonomy Permalink Slug

This simple solution enables you to customize the permalinks for your custom post types and CPT taxonomy types.

All you need to do is modify the slug for the rewrite parameter included in the code which registers your CPT or taxonomy.

This is the line which includes the slug custom-post-type-slug you can modify:

'rewrite' => array( 'slug' => 'custom-post-type-slug', 'with_front' => false ),

If you’ve also registered custom taxonomies, you would modify this slug custom-taxonomy-type-slug on this line in the code:

'rewrite'  => array( 'slug' => 'custom-taxonomy-type-slug', 'with_front' => false ),
Note: Don’t forget to re-save your permalinks after modifying the code as this will flush the rewrite rules which is needed to make the changes.

Here’s the full code which creates both a custom post type named portfolio and adds a page to create custom taxonomies for the portfolio CPT.

The code is included in the Executive Pro child theme by StudioPress and works in any theme.

Was This Tutorial Helpful?

Free

$0

Access only to all free tutorials per month.



Monthly

$75

Access to 10 premium tutorials per month.


Tutorial Request


Includes code guarantee and coding support.

Yearly

$500

Access to 15 premium tutorials per month.


Monthly Tutorial Request


Includes code guarantee and priority coding support.