WordPress主题(独立主题需要index.php文件错误)

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

WordPress主题(独立主题需要index.php文件错误)

文章图片
我不明白为什么会这样, 因为我有一个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

这是文件夹结构
WordPress主题(独立主题需要index.php文件错误)

文章图片
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文件夹中, 它将起作用。
【WordPress主题(独立主题需要index.php文件错误)】我不知道为什么会这样。但似乎我需要在style文件夹或style.css文件内放置一个索引文件, 将其放置在主文件夹中。

    推荐阅读