主题开发文档

必需的主题文件

💡 云策文档标注

概述

本文档介绍了 WordPress 主题开发中必需的文件,包括块主题和经典主题的不同要求,并强调了文件遵循模板标准的重要性。

关键要点

  • 块主题:参考 Create a Block Theme 构建块主题。
  • 经典主题:必须包含必需的主题文件,遵循主题团队设定的模板文件标准。
  • 必需文件:style.css(主样式表,包含主题信息)、index.php(主模板文件,用于首页)、comments.php(评论模板,支持线程评论和引用通告)、screenshot(主题截图,尺寸不超过 1200 x 900px)。
  • 其他文件:虽然这些是主题审核团队接受主题到 WordPress.org 目录的唯一必需文件,但可以使用其他模板文件。

📄 原文内容
Block theme: See Create a Block Theme for building a block theme

Classic themes must  include the required theme files. These files must follow template file standards set by the themes team. For Classic themes, additional standard template files are recommended to use. Learn more about the Organizing Theme Files.

Classic Themes Required Theme Files

  1. style.css
    Your theme’s main stylesheet file. This file will also include information about your theme, such as author name, version number, and plugin URL, in it’s header.
  2. index.php
    The main template file for your theme. This will be the template for the homepage on your site unless a static front page is specified. If you only include this template file, it must include all functionality of your theme. However, you can use as many relevant template files as you want in your theme.
  3. comments.php
    The comment template which is included wherever comments are allowed. This file should provide support for threaded comments and trackbacks, and should style author comments differently then user comments. See the Comments page for more information.
  4. screenshot
    In the WordPress.org theme directory, the screenshot acts as a visual indicator of what your theme looks like. It is visible both in the web view and in the admin dashboard. The screenshot must not be bigger than 1200 x 900px. 

While these files are the only files required by the theme review team for acceptance into the WordPress.org theme directory, you may use other template files. Of course, any file mentioned in the tutorial in this handbook may be used in your theme.