gpt4 book ai didi

WordPress 自定义帖子模板无法加载

转载 作者:行者123 更新时间:2023-12-02 23:22:50 26 4
gpt4 key购买 nike

我创建了一个自定义帖子,并制作了一个名为 single-postname.php 的模板文件

在我被重定向回主页之前,我无法加载模板文件,但刷新 .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 );

文件名 = single-conversation.php

最佳答案

根据模板层次结构,如果您希望输出自定义帖子类型“xyz”下所有帖子的存档,那么您将创建一个名为“archive-xyz.php”的文件并将其放入页面模板中目录。如果您希望在自定义帖子类型“xyz”下输出单个帖子,那么 WordPress 将查找名为“single-xyz.php”的文件。

http://codex.wordpress.org/Template_Hierarchy

这是我试图阐明的:)

关于WordPress 自定义帖子模板无法加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15443495/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com