我有一个自定义内容类型,名为events
我使用以下函数进行注册:
add_action(\'init\', \'events_post_init\');
function events_post_init() {
register_post_type( \'events\',
array(
\'labels\' => array(
\'name\' => \'Events\',
\'singular_name\' => \'Event\',
\'add_new\' => \'Create new\',
\'add_new_item\' => \'Create new event\',
\'all_items\' => \'All events\',
\'view_item\' => \'View event\',
\'search_items\' => \'Search events\',
\'not_found\' => \'No events found\',
\'not_found_in_trash\' => \'No events found in trash\',
\'menu_name\' => \'Events\',
),
\'rewrite\' => array(
array(\'slug\' => \'events\')
),
\'public\' => true,
\'has_archive\' => true,
\'show_ui\' => true,
\'menu_position\' => 6,
\'supports\' => array(\'thumbnail\', \'editor\', \'title\', \'excerpt\'),
)
);
}
现在,我想添加一个页面,用于在访问时显示事件的存档
/events/
, 因此,我创建了一个名为
page-events.php
然后添加了一个名为
Event Archive
弹头等于
events
及以下
Page Attribute
我已经选择了刚创建的新模板
问题是,当我转到指定的url时,模板没有被使用。但是如果我取消对
register_post_type()
然后它被加载了?