我已经创建了一个自定义帖子类型,并且正在尝试使用自定义模板来显示内容。为什么我的自定义文章类型没有使用我的自定义模板?
我的模板文件被命名为single-event.php
< - 错误在这里
我的自定义后类型代号为:
function create_post_type() {
$args = array(
'labels' => array(
'name' => __('Événement'),
'singular_name' => __('Événement'),
'add_new' => __('Nouvel Événement')
),
'public' => true,
'has_archive' => true,
'taxonomies' => array('event_data'),
'menu_position' => 5,
'supports' => array('title', 'editor', 'thumbnail', 'excerpt'),
'rewrite' => array('slug' => 'event')
);
register_post_type('event',$args);
}
我的自定义模板看起来是这样的:
<?php get_header(); ?>
<div id="event" class="full-width-container single-post">
TEEEEEEEST
</div>
<?php get_footer(); ?>
在我的浏览器中打开自定义职位,地址为:
http://my.site.no/?event=my-custom-post-title
但为什么它使用single.php
而不是single-event.php
?我错过了什么?
我的第一个inclincation是他们是一个加载single-event.php的问题,就像权限问题或代码无效。可能会像从文件开头丢失“<?php”一样简单。 –
这不是一个代码问题(请参阅使用模板代码更新的Q),并且没有理由说它应该是权限问题。其他一切正常。 – Steven
虽然是正确的,不是我。这是一个加载single-event.php问题;) 很高兴你做到了,这些东西通常是一些烦人的小事! –