我对定义为层次结构的自定义帖子类型的模板有点困惑。我将CPT设置为hierarchy,这并不是为了有嵌套的层次结构,而是为了让它们可以通过简单的页面排序插件排序。代码如下:
register_post_type(
\'case_study\', array(
\'label\' => _x( \'case studies\', \'post type plural name\' ),
\'labels\' => array(
\'name\' => _x( \'Case studies\', \'post type general name\' ),
\'singular_name\' => _x( \'Case study\', \'post type singular name\' ),
\'menu_name\' => _x( \'Case studies\', \'admin menu\' ),
\'name_admin_bar\' => _x( \'Case study\', \'add new on admin bar\' ),
\'add_new\' => _x( \'Add New\', \'case study\' ),
\'add_new_item\' => __( \'Add New Case study\' ),
\'new_item\' => __( \'New Case study\' ),
\'edit_item\' => __( \'Edit Case study\' ),
\'view_item\' => __( \'View Case study\' ),
\'all_items\' => __( \'All Case studies\' ),
\'search_items\' => __( \'Search Case studies\' ),
\'parent_item_colon\' => __( \'Parent Case studies:\' ),
\'not_found\' => __( \'No Case studies found.\' ),
\'not_found_in_trash\' => __( \'No Case studies found in Trash.\' )
),
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'show_in_nav_menus\' => true,
\'show_in_menu\' => true,
\'show_in_admin_bar\' => true,
\'menu_position\' => 20, // Below Pages
\'menu_icon\' => \'dashicons-clipboard\', // @link https://developer.wordpress.org/resource/dashicons/
\'query_var\' => false,
\'rewrite\' => array( \'slug\' => \'case-study\', \'with_front\' => false ),
\'capability_type\' => \'case_study\',
\'map_meta_cap\' => false,
\'capabilities\' => array(
\'publish_posts\' => \'publish_case_studies\',
\'edit_posts\' => \'edit_case_studies\',
\'edit_others_posts\' => \'edit_others_case_studies\',
\'delete_posts\' => \'delete_case_studies\',
\'delete_others_posts\' => \'delete_others_case_studies\',
\'read_private_posts\' => \'read_private_case_studies\',
\'edit_post\' => \'edit_case_study\',
\'delete_post\' => \'delete_case_study\',
\'read_post\' => \'read_case_study\',
),
\'has_archive\' => false,
\'hierarchical\' => true, // Set to true to allow ordering
\'supports\' => array( \'title\', \'editor\', \'custom-fields\', \'thumbnail\', \'revisions\', \'pilau-author\' ),
\'taxonomies\' => array( \'topic\' ),
)
);
默认情况下,分层CPT使用该页面。php模板,而不是单一模板。php——我花了一段时间才意识到这一点,但这是有道理的。
然而,现在我想专门为这个CPT和single-case\\u研究创建一个模板。php不工作。page-case\\u也没有研究。php。
如何专门为分层CPT创建模板?