页面是这样工作的,所以您可以使用页面或create a new post type (您需要hierarchical => true
:
function codex_custom_init() {
$labels = array(
\'name\' => _x(\'Books\', \'post type general name\', \'your_text_domain\'),
\'singular_name\' => _x(\'Book\', \'post type singular name\', \'your_text_domain\'),
\'add_new\' => _x(\'Add New\', \'book\', \'your_text_domain\'),
\'add_new_item\' => __(\'Add New Book\', \'your_text_domain\'),
\'edit_item\' => __(\'Edit Book\', \'your_text_domain\'),
\'new_item\' => __(\'New Book\', \'your_text_domain\'),
\'all_items\' => __(\'All Books\', \'your_text_domain\'),
\'view_item\' => __(\'View Book\', \'your_text_domain\'),
\'search_items\' => __(\'Search Books\', \'your_text_domain\'),
\'not_found\' => __(\'No books found\', \'your_text_domain\'),
\'not_found_in_trash\' => __(\'No books found in Trash\', \'your_text_domain\'),
\'parent_item_colon\' => \'\',
\'menu_name\' => __(\'Books\', \'your_text_domain\')
);
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => _x( \'book\', \'URL slug\', \'your_text_domain\' ) ),
\'capability_type\' => \'post\',
\'has_archive\' => true,
\'hierarchical\' => true,
\'menu_position\' => null,
\'supports\' => array( \'title\', \'editor\', \'author\', \'thumbnail\', \'excerpt\', \'comments\' )
);
register_post_type(\'book\', $args);
}
add_action( \'init\', \'codex_custom_init\' );