wordpress5.3 主题文件目录结构

虽然从技术上讲,WordPress主题仅需要两个文件(index.phpstyle.css),但它们通常由许多文件组成。这意味着它们会很快变得杂乱无章!

主题文件夹和文件结构

WP默认的自带主题是非常好的示例。例如,以下是  Twenty Seventeen 主题的文件结构

assets (dir)
      - css (dir)
      - images (dir)
      - js (dir)
inc (dir)
template-parts (dir)
      - footer (dir)
      - header (dir)
      - navigation (dir)
      - page (dir)
      - post (dir)
404.php
archive.php
comments.php
footer.php
front-page.php
functions.php
header.php
index.php
page.php
README.txt
rtl.css
screenshot.png
search.php
searchform.php
sidebar.php
single.php
style.css

 您可以看到主要主题模板文件位于根目录中,而JavaScript、CSS、图像位于 assets 目录中,模板部分位于 template-parts 的相应子目录下,并且与核心功能相关的功能集合被放在inc目录中。

目前,WordPress主题内没有必需的文件夹。但是,WordPress默认情况下会识别以下文件夹。

style.css  应该位于主题的根目录中,而不是CSS目录中。

发布了159 篇原创文章 · 获赞 45 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/lsmxx/article/details/104148816