大家好我用xampp开发wordpress主题localy我将固定链接更改为/%category%/%postname%/并且Everythings工作正常但是在我创建自定义帖子类型后永久链接我的常规帖子链接给我错误404页面和我的自定义帖子类型链接工作正常,当我取消自定义帖子类型时,我的常规帖子链接再次正常工作,2天搜索但没有坚决。
这是我的自定义帖子类型代码
<?php
function name_post(){
register_post_type('name',
array(
'labels' => array(
'name' => 'Names', 'wp_hours',
'singular_name' => 'Name', 'wp_hours',
'all_items' => 'All Names', 'wp_hours',
'add_new' => 'Add New', 'wp_hours',
'add_new_item' => 'Add New Name', 'wp_hours',
'edit' => 'Edit', 'wp_hours',
'edit_item' => 'Edit Name', 'wp_hours',
'new_item' => 'New Name', 'wp_hours',
'view_item' => 'View Names', 'wp_hours',
'search_items' => 'Search Names', 'wp_hours',
'not_found' => 'Nothing found in Database', 'wp_hours',
'not_found_in_trash' => 'Nothing found in Trash', 'wp_hours',
'parent_item_colon' => ''
),
'public' => true,
'has_archive' => 'name',
'public_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'capaility' => 'post',
'menu_position' => 5,
'rewrite' => array('slug' => 'name'),
'menu_icon' => 'dashicons-groups',
'supports' => array('title', 'editor', 'thumbnail', 'excerpt', 'custom-fields'),
'taxonomies' => array('category', 'post_tag')
));
}
add_action('init','name_post');
function names_taxonomies(){
register_taxonomy(
'Country',
'name',
array(
'label' => __('Conutry'),
'rewrite' => array('slug' => 'country'),
'hierarchical' => ture,
)
);
register_taxonomy(
'Age',
'name',
array(
'label' => __('Age'),
'rewrite' => array('slug' => 'age'),
'hierarchical' => false,
)
);
}
add_action('init', 'names_taxonomies');
function my_rewrite_flush() {
my_custom_posttypes();
flush_rewrite_rules();
}
register_activation_hook( __FILE__, 'my_rewrite_flush' );
?>