1

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

我的functions.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

4

1 回答 1

2

您使用了错误的数组,请改用它

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

于 2013-09-06T13:56:04.890 回答