我使用自定义帖子类型UI注册了一个自定义帖子类型,并创建了一个归档页面,并将其命名为archive recipe。php,“recipe”是我的自定义帖子类型名称。但它不起作用,而是使用默认值archive.php
. 我设置了has-archive
到true
但仍然不起作用。如何解决这个问题?
代码如下:
register_post_type(
\'recipe\', array(
\'label\' => \'Recipe\',
\'description\' => \'This is a Recipe Custom Post Type\',
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'capability_type\' => \'post\',
\'hierarchical\' => true,
\'rewrite\' => array(\'slug\' => \'\'),
\'query_var\' => true,
\'has_archive\' => true,
\'exclude_from_search\' => false,
\'supports\' => array(\'title\',\'editor\',\'excerpt\',\'trackbacks\',\'custom-fields\',\'comments\',\'revisions\',\'thumbnail\',\'author\',\'page-attributes\',),
\'labels\' => array (
\'name\' => \'Recipe\',
\'singular_name\' => \'Recipe\',
\'menu_name\' => \'Recipe\',
\'add_new\' => \'Add Recipe\',
\'add_new_item\' => \'Add New Recipe\',
\'edit\' => \'Edit\',
\'edit_item\' => \'Edit Recipe\',
\'new_item\' => \'New Recipe\',
\'view\' => \'View Recipe\',
\'view_item\' => \'View Recipe\',
\'search_items\' => \'Search Recipe\',
\'not_found\' => \'No Recipe Found\',
\'not_found_in_trash\' => \'No Recipe Found in Trash\',
\'parent\' => \'Parent Recipe\',
),
)
);