我创建了一个自定义帖子类型。这是一本书,我的url就像一个例子。com/book/a-book我展示了有关示例的书籍。com/books,但有一个例子。com/book如何删除该URL或显示404。在本例中,我的站点地图显示url:example。com/书本
function book_post_type() {
$labels = array(
\'name\' => _x( \'Books\', \'Post Type General Name\', \'sv\' ),
\'singular_name\' => _x( \'Book\', \'Post Type Singular Name\', \'sv\' ),
\'menu_name\' => __( \'Books\', \'sv\' ),
\'parent_item_colon\' => __( \'Parent Book\', \'sv\' ),
\'all_items\' => __( \'All Books\', \'sv\' ),
\'view_item\' => __( \'View Book\', \'sv\' ),
\'add_new_item\' => __( \'Add New Book\', \'sv\' ),
\'add_new\' => __( \'Add New\', \'sv\' ),
\'edit_item\' => __( \'Edit Book\', \'sv\' ),
\'update_item\' => __( \'Update Book\', \'sv\' ),
\'search_items\' => __( \'Search Books\', \'sv\' ),
\'not_found\' => __( \'Not Found\', \'sv\' ),
\'not_found_in_trash\' => __( \'Not Found In Trash\', \'sv\' ),
);
$args = array(
\'label\' => __( \'books\', \'sv\' ),
\'description\' => __( \'Books\', \'sv\' ),
\'labels\' => $labels,
\'supports\' => array( \'title\', \'thumbnail\', \'editor\', \'revisions\', ),
\'hierarchical\' => false,
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'show_in_nav_menus\' => true,
\'show_in_admin_bar\' => false,
\'menu_position\' => 5,
\'can_export\' => true,
\'has_archive\' => false,
\'exclude_from_search\' => false,
\'publicly_queryable\' => true,
\'capability_type\' => \'page\',
);
register_post_type( \'book\', $args );
}
add_action( \'init\', \'book_post_type\', 0 );