主题开发文档

💡 云策文档标注

概述

本文档深入解析 WordPress 模板文件,按它们显示的文章类型进行分类,并提供实际用例说明。重点在于理解模板文件如何基于文章类型进行组织,而非 WordPress 的固有分类。

关键要点

  • 模板文件按显示的文章类型分类:文章模板文件(Post post type)、页面模板文件(Page post type)、附件模板文件(attachment post type)、自定义文章类型模板文件(custom post types)。
  • WordPress 本身不严格区分模板文件类型,因为许多文件(如 index.php 或 search.php)可显示多种文章类型。
  • 文档还涵盖部分和杂项模板文件,这些文件虽重要但不直接显示文章类型。

📄 原文内容

We introduced template files earlier in the handbook.  This next section is going to break up the different template files through the post types that they display and provide a more in depth explanation of the purpose for these template files.  You’ll also get a handle on some practical use cases for the different template files.

You’ll start with post template files that deal with displaying the Post post type.  Then you’ll look at page template files that display the Page post type and drill down into specific page templates that WordPress has built in to its functionality.  Next you’ll learn about attachment template files which display the attachment post type.  You’ll also learn about how to display custom post types that are built by a plugin in the custom post type templates.  Lastly, you’ll touch on some partial and miscellaneous template files which are important to include but don’t necessarily display post types.

 It’s important to understand WordPress doesn’t really break down template files down into specific types of template files such as post template files or attachment template files. Especially since many template files, such as index.php or search.php can display many different post types. To help you reference specific template files this handbook is categorizing them based on the post types they can display.