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.
Leave a Reply
You must be logged in to post a comment.