WordPress的自定义文章模板将不会加载
问题描述:
我创建了一个自定义后,并作了题为模板文件的单postname.phpWordPress的自定义文章模板将不会加载
我不能得到的模板文件加载之前,我只想得到重新直接回到主页,但在刷新.htaccess文件后,我只是得到一个空白页面。
我试着删除并再次添加帖子,更改了永久链接几次,并改变了主题,似乎没有任何工作。有什么我可以做的尝试迫使WordPress再次寻找文件?
的register_post_type
$labels = array(
'name' => _x('Conversations', 'conversation'),
'singular_name' => _x('Conversation', 'conversation'),
'add_new' => _x('Add New', 'conversation'),
'add_new_item' => _x('Add New Conversation', 'conversation'),
'edit_item' => _x('Edit Conversation', 'conversation'),
'new_item' => _x('New Conversation', 'conversation'),
'view_item' => _x('View Conversation', 'conversation'),
'search_items' => _x('Search Conversations', 'conversation'),
'not_found' => _x('No conversations found', 'conversation'),
'not_found_in_trash' => _x('No conversations found in Trash', 'conversation'),
'parent_item_colon' => _x('Parent Conversation:', 'conversation'),
'menu_name' => _x('Conversations', 'conversation'),
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'description' => 'conversation between users on the site',
'supports' => array('title', 'excerpt', 'author', 'comments', 'custom-fields'),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 20,
//'menu_icon' => 'http://findicons.com/files/icons/2229/social_media_mini/24/google_talk.png',
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'capability_type' => 'post'
);
register_post_type('conversation', $args);
文件名=单conversation.php
答
根据模板层次,如果你是在自定义后键入“XYZ”希望输出的所有帖子的存档,然后你会创建一个名为“archive-xyz.php”的文件并将其放入你的page-templates目录中。如果您希望在自定义帖子类型“xyz”下输出单个帖子,则WordPress将查找名为“single-xyz.php”的文件。
http://codex.wordpress.org/Template_Hierarchy
有我的企图澄清:)
有作为'单postname.php'没有这样的模板,你最有可能的意思是'单posttype.php'?如果这样向我们展示自定义帖子类型代码和模板文件的名称。 – user2019515 2013-03-16 02:32:44
这就是一切 – 2013-03-18 19:26:10
在上周末,它开始工作,必须是缓存问题,但只要这个问题可以帮助人们,如果你写一个解释文件命名的答案,我会让它成为答案。 – 2013-03-18 19:30:07