我有一个自定义的帖子类型,叫做Treatment
.
根据我对WordPress的理解,archive.php
将始终使用,除非archive-{posttype}.php
.
出于某种原因,存档页改为使用landing-page.php
(我的首页模板),而我似乎无法让它使用其他任何东西。即使有archive.php
和archive-treatment.php
目前
有什么想法吗?
has_archive
设置了,我肯定看到了正确的URL。如果我设置has_archive
到false
它变成了404错误。
这是我的register_custom_post_type()
对于治疗:
function register_custom_post_type() {
register_post_type( \'treatment\', array(
\'labels\' => array(
\'name\' => _x( \'Treatments\', \'post type general name\', \'nsc-treatments\' ),
\'singular_name\' => _x( \'Treatment\', \'post type singular name\', \'nsc-treatments\' ),
\'menu_name\' => _x( \'Treatments\', \'admin menu\', \'nsc-treatments\' ),
\'name_admin_bar\' => _x( \'Treatment\', \'add new on admin bar\', \'nsc-treatments\' ),
\'add_new\' => _x( \'Add New\', \'treatment\', \'nsc-treatments\' ),
\'add_new_item\' => __( \'Add New Treatment\', \'nsc-treatments\' ),
\'new_item\' => __( \'New Treatment\', \'nsc-treatments\' ),
\'edit_item\' => __( \'Edit Treatment\', \'nsc-treatments\' ),
\'view_item\' => __( \'View Treatment\', \'nsc-treatments\' ),
\'all_items\' => __( \'All Treatments\', \'nsc-treatments\' ),
\'search_items\' => __( \'Search Treatments\', \'nsc-treatments\' ),
\'parent_item_colon\' => __( \'Parent Treatment:\', \'nsc-treatments\' ),
\'not_found\' => __( \'No treatment found.\', \'nsc-treatments\' ),
\'not_found_in_trash\' => __( \'No treatment found in Trash.\', \'nsc-treatments\' ),
),
// Frontend
\'has_archive\' => \'cosmetics/treatments\',
\'public\' => false,
\'publicly_queryable\' => false,
// Admin
\'capability_type\' => \'post\',
\'menu_icon\' => \'dashicons-screenoptions\',
\'menu_position\' => 10,
\'query_var\' => true,
\'show_in_menu\' => true,
\'show_ui\' => true,
\'supports\' => array(
\'title\',
\'author\',
),
) );
我也尝试过改变
has_archive => \'cosmetics/treatments\'
收件人:
\'has_archive\' => \'true\',
\'rewrite\' => array( \'slug\' => \'cosmetics/treatments\' ),
正如我在其他与此主题相关的答案中所看到的。
主题以下划线为基础,不改变引擎盖下的任何内容。只添加了CSS、模板部分和自定义帖子类型。
每次更改后,我都会重置永久链接。
非常感谢您的帮助,因为我对Wordpress还是比较陌生的