如何在 WordPress 中显示自定义帖子类型下拉模板的不同标题
我有一个名为 cme-education
的自定义帖子类型,它有一个下拉菜单,用于选择自定义帖子类型模板(与 WordPress 中页面的页面模板下拉菜单类似)。当我选择模板时,它可以工作,但是我希望能够显示该模板的不同标题,但我不确定如何实现这一点。
我的下拉 CPT 模板代码位于 template-in-conversation.php 文件
<?php
/*
Template Name: IN CONVERSATION
Template Post Type: cme-education
*/
?>
<?php get_header(); ?>
,然后我有一个头文件,其中有一个 if 语句来根据条件显示关联的头 header.php 文件
if(is_singular('in-conversation')){
get_template_part('includes/headers/header_in_convo');
} else {
echo "not found";
}
I have a Custom post type called cme-education
which has a drop down to select a custom post type template (similarly how you would with a page template drop down for pages in wordpress). When I select the template, it works however, I want to be able to show a different header for that template but I am not sure how to achieve that.
my code for the drop down CPT template is in
template-in-conversation.php file
<?php
/*
Template Name: IN CONVERSATION
Template Post Type: cme-education
*/
?>
<?php get_header(); ?>
and then I have a header file which has an if statement to show the associated headers based on the condition
header.php file
if(is_singular('in-conversation')){
get_template_part('includes/headers/header_in_convo');
} else {
echo "not found";
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要为此添加一个自定义头文件,例如
header-in_convo.php
。然后你可以这样做:
请参阅此处
You need to add a custom header file for that like
header-in_convo.php
.Then you could do this:
See here