模板下拉列表未显示在Wordpress管理员页面中
我正在做一个基于Wordpress的项目,我刚刚上传了一个模板文件,为安装添加了一个新模板。我正在创建一个使用新模板的新页面,突然,“页面属性”框中的“模板”下拉列表消失了 我正在使用Wordpress 3.0.1 更新:模板下拉列表未显示在Wordpress管理员页面中,wordpress,wordpress-theming,Wordpress,Wordpress Theming,我正在做一个基于Wordpress的项目,我刚刚上传了一个模板文件,为安装添加了一个新模板。我正在创建一个使用新模板的新页面,突然,“页面属性”框中的“模板”下拉列表消失了 我正在使用Wordpress 3.0.1 更新: 我看到一个站点,它告诉我恢复到默认模板,然后返回到我的自定义模板。显然,它起了作用,但我仍然对是什么触发了这个bug感到困惑。此外,任何关于这个bug的额外知识或指针都会有很大帮助,因为我的工作要求我修补这个bug(并可能将bug修复提交给Wordpress)。谢谢 我在Wo
我看到一个站点,它告诉我恢复到默认模板,然后返回到我的自定义模板。显然,它起了作用,但我仍然对是什么触发了这个bug感到困惑。此外,任何关于这个bug的额外知识或指针都会有很大帮助,因为我的工作要求我修补这个bug(并可能将bug修复提交给Wordpress)。谢谢 我在WordPress 3.2.1中遇到了完全相同的问题。我添加了一个新模板,菜单从页面添加/编辑屏幕上消失。解决方案是切换回默认的twentyeleven主题结束,然后直接切换回我的自定义主题。“模板”下拉列表再次出现 顺便说一句,你说“恢复到默认模板,并返回到我的自定义模板”,但我很确定你的意思是主题。我猜你在这里看到的是: 看起来这个bug至少已经存在了几年了。我提交了一份报告:
我找到了一个不同的解决方案。我重新激活了自定义主题,但问题仍然存在。。然后在自定义页面模板代码的最上面部分,它实际定义了模板的名称,如下所示:
<?php
/*
Template Name: Front Page
*/
?>
我这样做:
<?php
/**
* Template Name: Front Page
*/
?>
然后刷新了管理面板,它出现了。看起来有点奇怪,但它对我来说是有效的。很高兴与大家分享 森奇卡很合适。我也有同样的问题,但后来它通过以下方式解决了:
<?php
/**
* Template Name: Front Page
*/
?>
如果已从模板目录中禁用或删除style.css,则它也将不起作用 因此,模板目录上必须有style.css,然后将显示模板目录。当您试图从模板目录中删除style.css或从css文件夹中使用style.css时,必须在模板目录中放置一个style.css
谢谢将style.css放在主题目录中,而不是css文件夹中。或
<?php
/*
Template Name: Front Page
*/
?>
“Template Name:”之间不能有空格。我之前遇到过这个问题,经过大量搜索后找到了一个简陋的解决方案——有时在安装中切换到另一个主题,然后切换回主主题会使模板出现。我知道这听起来很奇怪,但对我来说已经有一段时间了。我有这个问题已经两天了。这个论坛和后来的几个测试完成了这项工作。这是我这一部分所缺少的
确保主题文件夹中有style.css style.css文件顶部必须有有效的注释部分。 这至少意味着:
/*!
Template: your-theme
*/
如果您使用的是SASS或更少,请确保在声明您的评论之后有一个“!”。删除您的评论部分是为了防止SASS或更少
确保一切都很好地解决。您可以进入“外观>主题”。在主题列表之后,如果没有什么,那么一切都应该是好的。否则,它将被写为“断开的主题”,您仍然需要解决一些问题。我通过确保主题根目录中的
style.css
包含主题注释来解决这个问题。我删除了整个样式表,它删除了模板下拉列表
将其放在主题根的style.css
顶部
/wp content/themes/YOUR_THEME/style.css
/*
Theme Name: Twenty Thirteen
Theme URI: http://wordpress.org/themes/twentythirteen
Author: the WordPress team
Author URI: http://wordpress.org/
Description: The 2013 theme for WordPress takes us back to the blog, featuring a full range of post formats, each displayed beautifully in their own unique way. Design details abound, starting with a vibrant color scheme and matching header images, beautiful typography and icons, and a flexible layout that looks great on any device, big or small.
Version: 1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: black, brown, orange, tan, white, yellow, light, one-column, two-columns, right-sidebar, flexible-width, custom-header, custom-menu, editor-style, featured-images, microformats, post-formats, rtl-language-support, sticky-post, translation-ready
Text Domain: twentythirteen
This theme, like WordPress, is licensed under the GPL.
Use it to make something cool, have fun, and share what you've learned with others.
*/
或者如果你有一个自定义主题
/*
Theme Name: My Wordpress Theme
Theme URI: https://example.tk
Author: Me
Author URI: https://example.tk
Description: This is my custom theme
Version: 1.0
*/
我也遇到了同样的问题,问题是“模板名”和冒号之间的间距
/*
Template Name: template-name
*/
请确保冒号前没有空格。我知道这个问题太晚了,但我修正了它
版本:0.1 alpha
在文件夹/style.css的注释中
/*
Theme Name: Twenty Thirteen
Theme URI: http://wordpress.org/themes/twentythirteen
Author: the WordPress team
Author URI: http://wordpress.org/
Description: The 2013 theme for WordPress takes us back to the blog, featuring a full range of post formats, each displayed beautifully in their own unique way. Design details abound, starting with a vibrant color scheme and matching header images, beautiful typography and icons, and a flexible layout that looks great on any device, big or small.
Version: 1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: black, brown, orange, tan, white, yellow, light, one-column, two-columns, right-sidebar, flexible-width, custom-header, custom-menu, editor-style, featured-images, microformats, post-formats, rtl-language-support, sticky-post, translation-ready
Text Domain: twentythirteen
This theme, like WordPress, is licensed under the GPL.
Use it to make something cool, have fun, and share what you've learned with others.
*/
这是我的风格。css
完成我的主题
/*
Theme Name: Stockout Theme
Theme URI: http://stockout.com.uy/myTheme
Author: MauriPastorini
Author URI: http://stockout.com.uy
Description: This is a theme for stockout page
Version: 0.1 alpha
*/
我希望有人觉得这有用杰克·尼科尔森是对的!您需要确保style.css包含完整的注释。示例如下:
以前我是:
/*
Theme Name: Acadata
Theme URI: https://www.factorypattern.co.uk
Description: Custom
Author: Factory Pattern
Version: 1
License: GNU General Public License
License URI: license.txt
*/
然后我把它改成下面的,现在我可以看到我所有的模板
/*
Theme Name: Acadata
Theme URI: https://factorypattern.co.uk/
Description: Custom
Author: Factory Pattern
Author URI: https://factorypattern.co.uk/
Description: The Acadata theme for WordPress.
Version: 1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: black, brown, orange, tan, white, yellow, light, one-column, two-columns, right-sidebar, flexible-width, custom-header, custom-menu, editor-style, featured-images, microformats, post-formats, rtl-language-support, sticky-post, translation-ready
Text Domain: acadata
This theme, like WordPress, is licensed under the GPL.
Use it to make something cool, have fun, and share what you've learned with others.
*/
我找到了问题的根源。
它是主题根目录中的style.css
文件
它必须是“UNIX编码”
它必须有“主题名称”、“版本”等所有注释
如果您正在处理子主题,请特别设置style.css文件
/*
主题名称:主题名称
主题URI:http://mysite.com/
描述:这是xxx主题的自定义子主题
作者:我的名字
作者URI:http://mysite.com/
模板:模板名称(小写)
版本:0.1
*/
以下是“为我工作”和“在页面属性中显示模板”选项。只需将.php文件放在主题根文件夹中即可
<?php
/* template name: my custom template */
?>
我尝试了许多建议的答案。在我的情况下,没有一个起作用
模板下拉列表未显示的一个可能原因是主题文件夹中缺少index.php
只要创建一个空的,以防您的层次结构不需要。但该文件的存在使选项能够选择页面模板,并抑制选择主题页面中的错误消息。顺便说一句,sass已删除my child style.css中的内容。在我添加回注释后,模板下拉列表再次显示。 /* 主题名称:Sometheme子主题 描述:Sometheme的子主题。 模板:sometheme 版本:1.1 文本域:sometheme子对象
*/关于这个问题有很多很好的答案,但一个显而易见的解决方案,最初我没有想到,就是在仪表板>设置>阅读中反复检查是否要将“主页显示”设置为“静态页面”
assets (dir)
- css (dir)
- images (dir)
- js (dir)
inc (dir)
template-parts (dir)
- section-content.php
- template-contactus.php
404.php
archive.php
comments.php
footer.php
front-page.php
function.php
header.php
index.php
page.php
README.txt
rtl.css
screenshot.png
search.php
searchform.php
sidebar.php
single.php
style.php
<?php
/*
Template Name: Front Page
*/
<?php
/**
* Template Name: Blog Post
* Template Post Type: post, page
?>