• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2665

Original Genesis Tutorials & 5000+ Guaranteed Code

Snippets

  • Support
  • Newsletter
  • Videos
  • Log in

Premium Member? - Request custom code

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.

Custom Post Type

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

PHP Code

template_include

get_body_class

if else

array

class_exists

foreach

sprintf

add_action

printf

variable

Advertise · WPEngine · Genesis · Log in

  • How Premium Membership Works
  • Sign Up
  • Support
  • Subscription Details/Invoice
  • Tagged Tutorials
  • Access-Download Problems