独立主题需要有index.php模板文件,WordPress主题:独立主题需要index.php文件错误

编码-WordPress->主题时突然出现错误:

89f95327a89b661d645632c714510427.png

我不明白为什么会这样, 因为我有一个index.php页面。 CSS样式表也在那里。 style.css也有以下评论

style.css

Theme Name: samirTheme

Author: samir

Author URI: www.wordpress.com

Version: 1.0

Description: This is a cool theme

Template: Test1

这是文件夹结构

e967a2154ac721450f42ef83e0cd2a5e.png

WordPress的新手。为何主题被破坏而没有出现在wordpress中则如此困惑。有任何想法吗?

#1

解决方案解决方法实际上非常简单。我发现很难找到一个很好的答案资源, 所以我在这里回答。

缺少style.css:template:主题在标题中, 即

/*

Theme Name: samirTheme

Theme URI: http://example.com/twenty-fifteen-child/

Description: Twenty Fifteen Child Theme

Author: John Doe

Author URI: http://example.com

Template: twentyfifteen

Version: 1.0.0

License: GNU General Public License v2 or later

License URI: http://www.gnu.org/licenses/gpl-2.0.html

Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready

Text Domain: twenty-fifteen-child

*/

#2

为了使WordPress将主题模板文件集识别为有效主题, style.css文件需要位于主题的根目录中, 而不是子目录中。

因此, 主主题css文件位于root目录中->然后加入其中包含所有样式的第二个样式表-如果你希望它位于/ css /

CSS标题示例:

/*

Theme Name: Twenty Seventeen

Theme URI: https://wordpress.org/themes/twentyseventeen/

Author: the WordPress team

Author URI: https://wordpress.org/

Description: Twenty Seventeen brings your site to life with immersive featured images and subtle animations. With a focus on business sites, it features multiple sections on the front page as well as widgets, navigation and social menus, a logo, and more. Personalize its asymmetrical grid with a custom color scheme and showcase your multimedia content with post formats. Our default theme for 2017 works great in many languages, for any abilities, and on any device.

Version: 1.0

License: GNU General Public License v2 or later

License URI: http://www.gnu.org/licenses/gpl-2.0.html

Text Domain: twentyseventeen

Tags: one-column, two-columns, right-sidebar, flexible-header, accessibility-ready, custom-colors, custom-header, custom-menu, custom-logo, editor-style, featured-images, footer-widgets, post-formats, rtl-language-support, sticky-post, theme-options, threaded-comments, translation-ready

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://developer.wordpress.org/themes/basics/main-stylesheet-style-css/

#3

我也一样我已经拥有所有必需的文件(因为两个文件仅需要索引和样式), 我注意到, 如果你有style.css文件的文件夹, 则会收到上述错误消息。

因此, 我进行了交叉检查, 甚至移动了, 并从主文件夹中删除了索引文件。

如果我从主文件夹中删除index.php文件, 并将其放在css文件夹中, 它将起作用。

我不知道为什么会这样。但似乎我需要在style文件夹或style.css文件内放置一个索引文件, 将其放置在主文件夹中。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值