Replacing slug in CPT
-
I’m using Workality theme for one of my projects, but to fit specifics of this project I need to change the defined custom post type permalink (slug), so changed the code:
register_post_type( 'works' , array( 'label'=>_x('Works','Type','dronetv'), 'description'=>__('Special type of post for creating project','dronetv'), 'labels' => $labels, 'public' => true, 'menu_position' => 5, 'show_ui' => true, 'show_in_menu' => true, 'publicly_queryable' => true, 'exclude_from_search' => true, 'query_var' => true, 'menu_icon'=>get_template_directory_uri() . '/images/portfolio_icon.png', 'rewrite' => true, 'capability_type' => 'post', 'hierarchical' => false, 'supports' => array( 'title', 'editor','thumbnail') ) );
to this one:
register_post_type( 'works' , array( 'label'=>_x('Works','Type','dronetv'), 'description'=>__('Special type of post for creating project','dronetv'), 'labels' => $labels, 'public' => true, 'menu_position' => 5, 'show_ui' => true, 'show_in_menu' => true, 'publicly_queryable' => true, 'exclude_from_search' => true, 'query_var' => true, 'menu_icon'=>get_template_directory_uri() . '/images/portfolio_icon.png', 'rewrite' => array('slug' => 'themes'), 'capability_type' => 'post', 'hierarchical' => false, 'supports' => array( 'title', 'editor','thumbnail') ) );
Now it works fine for me, my permalink was changed from “works” to “themes”, but I’n not sure if the changes I made is correct solution, I’m not code familiar, so please help me if I did something wrong?
If you have better solution for changing themes existing CPT slug, please share it with us.
Thanks
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Replacing slug in CPT’ is closed to new replies.