Cannot rename the slug for a custom post type

I cannot for the life of me change the slug of my custom post type. I’ve tried flush rewrite and re-saving my permalinks. But it still shows the old slug.

My functions.php

Read More
register_post_type( 'roofers-peakdistrict',
    array(
        'labels' => array(
            'name' => __( 'Peak District' ),
            'singular_name' => __( 'Roofers Peak District' ),
            'add_new' => 'Add New Peak District Page',
            'add_new_item' => 'Add New Peak District Page',
            'edit' => 'Edit Peak District Page',
            'edit_item' => 'Edit Peak District Page',
            'new_item' => 'New Peak District Page',
            'view' => 'View Peak District Page',
            'view_item' => 'View Peak District Page',
            'search_items' => 'Search Peak District Pages',
            'not_found' => 'No Peak District Pages found',
            'has_archive' => true,
            'slug' => 'roofers-peak-district'
            'hierarchical' => true,
            'not_found_in_trash' => 'No Peak District Pages found in Trash',
            'parent' => 'Parent Peak District Page', ),
            'public' => true,
            'supports' => array(
                'title',
                'editor',
                'thumbnail'
                ),
            'taxonomies' => array('category'),
            )
        );

My posts are coming out like http://mysite.com/roofers-peakdistrict/mypost

I need to change it so it’s http://mysite.com/roofers-peak-district/mypost

Related posts

Leave a Reply

1 comment

  1. you are using a wrong array
    use this instead

    register_post_type( 'roofers-peakdistrict',
        array(
            'labels' => array(
                'name' => __( 'Peak District' ),
                'singular_name' => __( 'Roofers Peak District' ),
                'add_new' => 'Add New Peak District Page',
                'add_new_item' => 'Add New Peak District Page',
                'edit' => 'Edit Peak District Page',
                'edit_item' => 'Edit Peak District Page',
                'new_item' => 'New Peak District Page',
                'view' => 'View Peak District Page',
                'view_item' => 'View Peak District Page',
                'search_items' => 'Search Peak District Pages',
                'not_found' => 'No Peak District Pages found', 
               ),
                'has_archive' => true,
                'rewrite' => array(
                      'slug'=>'roofers-peak-district'
                 ),
                'hierarchical' => true,
                'not_found_in_trash' => 'No Peak District Pages found in Trash',
                'parent' => 'Parent Peak District Page',
              'public' => true,
              'supports' => array(
                     'title',
                     'editor',
                     'thumbnail'
               ),
               'taxonomies' => array('category'),
        )
    

    );

    more details & examples see
    http://codex.wordpress.org/Function_Reference/register_post_type