我正在研究产品目录的WP主题。我的CTP有多个子类别,例如:
Vehicle -> Vehicle type -> Vehicle type -> Vehicle year -> Vehicle
或
Car -> SUV -> VW -> 2018 -> T-Roc
如何创建该结构?现在我的
functions.php
看起来像:
<?php
function custom_post_type() {
$labels = array(
\'name\' => _x( \'Cars\', \'Post Type General Name\', \'twentythirteen\' ),
\'singular_name\' => _x( \'Car\', \'Post Type Singular Name\', \'twentythirteen\' ),
\'menu_name\' => __( \'Cars\', \'twentythirteen\' ),
\'parent_item_colon\' => __( \'Parent Car\', \'twentythirteen\' ),
\'all_items\' => __( \'All Cars\', \'twentythirteen\' ),
\'view_item\' => __( \'View Car\', \'twentythirteen\' ),
\'add_new_item\' => __( \'Add New Car\', \'twentythirteen\' ),
\'add_new\' => __( \'Add New\', \'twentythirteen\' ),
\'edit_item\' => __( \'Edit Car\', \'twentythirteen\' ),
\'update_item\' => __( \'Update Car\', \'twentythirteen\' ),
\'search_items\' => __( \'Search Car\', \'twentythirteen\' ),
\'not_found\' => __( \'Not Found\', \'twentythirteen\' ),
\'not_found_in_trash\' => __( \'Not found in Trash\', \'twentythirteen\' ),
);
$args = array(
\'label\' => __( \'cars\', \'twentythirteen\' ),
\'description\' => __( \'Cars news and reviews\', \'twentythirteen\' ),
\'labels\' => $labels,
\'supports\' => array( \'title\', \'editor\', \'excerpt\', \'author\', \'thumbnail\', \'comments\', \'revisions\', \'custom-fields\', ),
\'taxonomies\' => array( \'category\' ),
\'hierarchical\' => false,
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'show_in_nav_menus\' => true,
\'show_in_admin_bar\' => true,
\'menu_position\' => 5,
\'can_export\' => true,
\'has_archive\' => true,
\'exclude_from_search\' => false,
\'publicly_queryable\' => true,
\'capability_type\' => \'page\',
);
register_post_type( \'cars\', $args );
}
add_action( \'init\', \'custom_post_type\', 0 );
?>