在 WordPress 3.2.x 中创建页面时缺少管理模板选择

发布于 2024-12-14 05:32:10 字数 348 浏览 4 评论 0原文

我使用的是 WordPress 3.2.1,

页面上缺少页面模板选择下拉列表(添加、编辑)

wp-admin > Pages >Add New > Page Attributes

我编辑模板页面默认页面,如下代码

/*
Template Name: New Template
*/

但模板下拉列表仍然不可见,我的旧版本 WordPress 默认显示。

以下是更多想法的屏幕截图 在此处输入图像描述

I am using WordPress 3.2.1 ,

Page template selection drop down is missing on Pages (Add,Edit)

wp-admin > Pages >Add New > Page Attributes

I Edit the Template Page Default page as below code

/*
Template Name: New Template
*/

But still the template drop down no visible , my older version of WordPress it display by default.

Following is the screen shot for more idea
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

·深蓝 2024-12-21 05:32:10

我通过添加以下典型代码解决了这个问题:

/*
Template Name: Custom
*/

不要在 Name: 之后添加任何空格

如果您也使用 template name: ,它也会起作用。

I solved this problem solved by adding the typical following code:

/*
Template Name: Custom
*/

Don't add any spaces after Name:

It'll work if you use template name: as well.

空宴 2024-12-21 05:32:10

它可能会帮助某人:检查您的 index.php 文件是否就位。

如果不存在,wordpress 会将模板视为已损坏,并且不会显示模板选择。

It might help someone: check if your index.php file is in place.

If it's not there, wordpress treats the template as corrupt and it doesn't display the template selection.

许一世地老天荒 2024-12-21 05:32:10

这应该很容易排除故障。页面模板工作的要求很简单:

模板需要将页面标题放在文件顶部,就像您所显示的那样(标题需要包含在 PHP 标签中,您可能只是没有添加它您的示例但我想确保您没有忽略它):

<?php
/*
Template Name: Custom
*/
?>

第二个要求是该文件位于主题文件夹的根目录中。

满足这两个要求后,它应该可以工作。如果它不起作用,您可能会遇到一些问题。我立即列出了一些:

  1. 如果文件损坏,您可能需要重新安装 WordPress
    在您上次更新期间。
  2. 可能有人使用用户更改了 WP-Admin 布局
    角色。

目前我能想到的就是这些,请告诉我结果如何。

This should be simple to troubleshoot. The requirements for the page template to work are straight forward:

The template needs the page title in the top of the file like you've shown (the title needs to be wrapped in a PHP tag, you probably just didn't add it with your example bu I want to make sure you havne't overlooked it):

<?php
/*
Template Name: Custom
*/
?>

The second requirement is that the file is in the root of the theme folder.

With those two requirements in place, it should work. If it isn't working you nave a few possible issues. I list a few off the top of my head:

  1. You might need to re-install WordPress in-case a file was corrupted
    during your last update.
  2. It's possible someone has altered the WP-Admin layout using users
    roles.

That's all I can thing of at the moment, let me know how it turns out.

ゞ花落谁相伴 2024-12-21 05:32:10

我有同样的问题。在我的例子中,实际上是模板目录中缺少 style.css 文件。
发生这种情况是因为 class-wp-theme.php 中的 get_post_templates() 首先检查错误。如果找到任何则返回一个空数组(不显示模板)。

这样做的副作用是保存页面会清除现有模板并使用 page.php 代替。

简而言之,如果主题的 error() 方法返回任何错误,则没有模板下拉列表。

希望对某人有帮助。

I had the same issue. It actually turned out to be a missing style.css file within the template directory in my case.
This happens because the get_post_templates() in class-wp-theme.php first checks for errors. If it finds any then it returns an empty array (no templates are displayed).

A side effect of this is that saving a page would clear the existing template and use the page.php instead.

So in short if the errors() method of your theme returns any errors then no templates dropdown.

hope that helps someone.

笑咖 2024-12-21 05:32:10

同样的问题,我发现在 WordPress 仪表板的外观面板中样式表丢失了。您不应重命名主题文件夹中的 style.css。

Same issued, I found out that in appearance panel in your WordPress dashboard the stylesheet is missing. You shouldn't rename the style.css in your theme folder.

甜警司 2024-12-21 05:32:10

不确定这是否会对任何人有帮助,但我们通过禁用主题并再次重新启用它解决了问题。我们在主题目录中还有一些其他未使用的主题文件夹,因此我们也将其删除。祝你好运,这是一个需要解决的非常随机的问题!

Not sure if this will help anyone, but we solved the problem by disabling our theme and re-enabling it again. We had some other theme folders in the theme directory that we weren't using so we deleted those out as well. good luck, it's a really random problem to solve!

谜泪 2024-12-21 05:32:10

是的!模板下拉列表未显示,因为您没有模板 那么如何解决这个问题::---

1 在主题中创建模板文件夹
2 在此文件夹中创建模板
喜欢:-

并且签入页面下拉菜单将出现。

yeah!template dropdown not showing because you have no template So how to solve this::---

1 create template folder in theme
2 create a template in this folder
like:-
<?php /* Template Name: Home */ echo "template"; ?>

and check-in page dropdown will be there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文