主题开发文档

💡 云策文档标注

概述

本文档介绍 WordPress 块模板系统,涵盖自定义模板和模板部件的构建方法,以及如何将它们集成到主题中。模板是构建网站的核心概念,决定了内容在浏览器中的呈现结构,对主题开发至关重要。

关键要点

  • 模板是 WordPress 主题开发的基础,用于定义网站内容的底层结构。
  • WordPress 块模板系统支持创建自定义模板和模板部件,并可通过主题集成。
  • 模板层级(Template Hierarchy)决定了 WordPress 如何根据用户查看的页面选择模板。
  • 模板部件(Template Parts)是可重用的组件,可以插入到顶级模板中。

📄 原文内容

Welcome to the Templates documentation. In this chapter you will learn how the WordPress block template system works, how to build custom templates and parts, and include them in your theme.

Templates are one of the core concepts of building websites, representing the underlying structure that presents your content in the browser. In many ways, they are the most important feature of developing WordPress themes.

Navigating this chapter

Use the below links to find the topic you are looking for in this chapter. Each section of the chapter is set up to offer a straightforward learning path toward learning how to build templates for those building their first theme. But if you are already familiar with the foundational concepts, feel free to skip ahead to the topic you want to learn more about.

  • Introduction to Templates: An overview of what templating is, how the templating system in WordPress works, and a look at the relationship between the template hierarchy, templates, and template parts.
  • Templates: How to build custom templates and include them in your WordPress theme.
  • Template Hierarchy: How WordPress decides which template to use based on the page the user is viewing.
  • Template Parts: How to build template parts and insert them into top-level templates.