无法重命名自定义帖子类型的 slug


Cannot rename the slug for a custom post type

我一生都无法更改自定义帖子类型的 slug。我尝试过刷新重写并重新保存我的永久链接。但它仍然显示了老蛞蝓。

我的函数.php

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'),
            )
        );

我的帖子像 http://mysite.com/roofers-peakdistrict/mypost 一样出来

我需要更改它,以便它 http://mysite.com/roofers-peak-district/mypost

您使用了错误的数组改用这个

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'),
    )

);

更多詳情和例子見http://codex.wordpress.org/Function_Reference/register_post_type