Wordpress 管理员页面中未显示模板下拉菜单

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3987773/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 18:39:51  来源:igfitidea点击:

Template Dropdown not showing up within Wordpress administrator page

wordpresswordpress-theming

提问by Ardee Aram

I am working on a Wordpress-based project, and I just added a new template to the installation by uploading a template file. I was creating a new page that will use my new template, when suddenly, the "Template" dropdown in the "Page Attributes" box is gone.

我正在处理一个基于 Wordpress 的项目,我只是通过上传模板文件向安装添加了一个新模板。我正在创建一个将使用我的新模板的新页面,突然,“页面属性”框中的“模板”下拉列表消失了。

I am using Wordpress 3.0.1.

我正在使用 Wordpress 3.0.1。

Update: I saw a site which told me to revert to the default template, and back to my custom template. Apparently it worked, but I am still baffled on what triggers this bug. Also, any additional knowledge or pointers on this bug would be a great help since my job requires me to patch this (and possibly submit the bug fix to Wordpress). Thanks!

更新:我看到一个网站告诉我要恢复到默认模板,并返回到我的自定义模板。显然它有效,但我仍然对触发此错误的原因感到困惑。此外,有关此错误的任何其他知识或指示都会有很大帮助,因为我的工作需要我对此进行修补(并可能将错误修复提交给 Wordpress)。谢谢!

回答by Sandeep Josan

If you have disabled or removed the style.css from the template directory then also it will not work.

如果您从模板目录中禁用或删除了 style.css,那么它也将无法工作。

So there must be the style.css on template directory then the templates directory will be shown. When you try to remove the style.css from the template directory or using style.css from css folder, then you must be put one style.css on template directory.

所以模板目录上必须有 style.css 然后模板目录将被显示。当您尝试从模板目录中删除 style.css 或使用 css 文件夹中的 style.css 时,您必须将一个 style.css 放在模板目录中。

Thanks

谢谢

回答by Dominic Francis

Morichika is spot on. I had the same problem, but then it sorted itself out by doing:

Morichika 是现场。我遇到了同样的问题,但后来通过以下方式解决了:

<?php
    /**
    * Template Name: Front Page
    */
?>

回答by morichika

I have found a different solution for this. I reactivated my custom theme but then problem persisted.. then in the top most section of the code for the custom page template where it actually defines the name of the template like this:

我为此找到了不同的解决方案。我重新激活了我的自定义主题,但问题仍然存在..然后在自定义页面模板代码的最顶部部分,它实际上定义了模板的名称,如下所示:

<?php
    /*
     Template Name: Front Page
    */
?>

I did this:

我这样做了:

<?php
    /**
    * Template Name: Front Page
    */
?>  

Then refreshed the admin panel and it appeared.Seems a bit weird but it worked for me. Feel happy to share this.

然后刷新管理面板,它出现了。看起来有点奇怪,但对我有用。很高兴分享这个。

回答by user5599875

Put style.css in your theme directory, instead of the css folder. Or

将 style.css 放在您的主题目录中,而不是 css 文件夹中。或者

<?php
    /*
     Template Name: Front Page
    */
?>

There must not space between "Template Name:".

“模板名称:”之间不能有空格。

回答by Hyman

I managed to fix this by making sure the style.cssin the theme root contained the theme comments. I deleted the whole stylesheet and it removed the templates dropdown.

我设法通过确保style.css主题根目录中包含主题注释来解决此问题。我删除了整个样式表并删除了模板下拉列表。

Put this at the top of your theme root's style.css.

把它放在你的主题根目录的顶部style.css

/wp-content/themes/YOUR_THEME/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.
*/

https://codex.wordpress.org/Theme_Development#Theme_Stylesheet

https://codex.wordpress.org/Theme_Development#Theme_Stylesheet

Or if you have a custom theme...

或者,如果您有自定义主题...

/*
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
*/

回答by sjscitp

I had the exact same problem with WordPress 3.2.1. I added a new template and the menu disappeared from the page add/edit screen. The solution was to switch back to the default twentyeleven theme end then right back to my custom theme. The templates drop-down began appearing again.

我在 WordPress 3.2.1 上遇到了完全相同的问题。我添加了一个新模板,菜单从页面添加/编辑屏幕中消失了。解决方案是切换回默认的 211 主题结束,然后回到我的自定义主题。模板下拉菜单又开始出现了。

BTW, you said "revert to the default template, and back to my custom template" but I'm pretty sure you meant theme. I'm guessing where you saw this was here:

顺便说一句,你说“恢复到默认模板,然后回到我的自定义模板”,但我很确定你的意思是theme。我猜你在哪里看到这个:

http://wordpress.org/support/topic/template-file-drop-down-not-appearing

http://wordpress.org/support/topic/template-file-drop-down-not-appearing

Looks like this bug has existed for a couple of years at least. I filed a report: http://core.trac.wordpress.org/ticket/18324

看起来这个错误至少已经存在几年了。我提交了一份报告:http: //core.trac.wordpress.org/ticket/18324

回答by Mauricio Pastorini

I know is super late for this question, but I fix it adding

我知道这个问题太晚了,但我修复它添加

Version: 0.1 alpha

Version: 0.1 alpha

in the comments of the themeFolder/style.css

在网友的评论中 themeFolder/style.css

This is my style.csscomplete for my theme

这是style.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
*/

I hope someone find this useful

我希望有人觉得这很有用

回答by Edgar Alloro

I tried many of the suggested answers. None worked in my case.

我尝试了许多建议的答案。在我的情况下没有任何工作。

A possible reason for the Template Dropdown not showing is a missing index.phpin your Theme folder.

模板下拉菜单未显示的可能原因是您的主题文件夹中缺少index.php模板。

Just create an empty one, in case your hierarchy does not need one. But the existance of that file enables the option to choose the page template and suppresses an error message in the Choose-Theme page btw

只需创建一个空的,以防您的层次结构不需要一个。但是该文件的存在使得可以选择页面模板并抑制选择主题页面中的错误消息 btw

回答by Gregory Bologna

sass had deleted the content in my child style.css. The template drop down shows again once I added back the comments. /* Theme Name: Sometheme Child Description: Child theme for Sometheme. Template: sometheme Version: 1.1 Text Domain: sometheme-child */

sass 删除了我的孩子 style.css 中的内容。一旦我添加回评论,模板下拉菜单再次显示。/* 主题名称:Sometheme Child 描述:Sometheme 的子主题。模板:sometheme 版本:1.1 文本域:sometheme-child */

回答by Najam ali shahid

I had this problem a while back and found one janky solution after a lot of search--sometimes switching to another theme in your install and then switching back to you primary theme will make your templates appear. I know that sounds weird, but worked for me for a while.

不久前我遇到了这个问题,经过大量搜索后找到了一个笨拙的解决方案 - 有时在安装中切换到另一个主题,然后切换回主主题将使您的模板出现。我知道这听起来很奇怪,但对我来说有效了一段时间。