主题开发文档

本手册面向谁?

💡 云策文档标注

概述

本手册是WordPress主题开发的独立资源,涵盖从基础到高级的主题创建原则,旨在帮助开发者构建自定义主题。

关键要点

  • 适合人群:希望从零创建主题、基于现有主题构建新主题、通过子主题扩展主题或理解主题工作原理的开发者。
  • 技能要求:建议具备HTML、CSS和PHP基础知识,JavaScript知识有助于前端交互;需能设置和配置WordPress网站以测试主题。
  • 内容范围:覆盖块主题和经典主题的基础知识,包括核心概念和高级主题章节,专注于主题构建基础,提供逐步指导和资源。

注意事项

  • WordPress及其块主题系统允许通过站点编辑器界面自定义和导出主题,但基本HTML、CSS和PHP知识能加速开发进程。
  • 经典主题完全基于代码构建,需要编辑相关语言的能力;手册不涵盖所有网站构建方面,而是聚焦主题开发基础。

📄 原文内容

The Theme Developer Handbook is a self-contained resource to help you learn the fundamental principles of creating a WordPress theme. It covers a range of topics that span the basics to advanced development.

You should read this handbook if you want to:

  • Create a theme based on nothing but your imagination
  • Build a new theme based on an existing one
  • Extend another theme by creating a child theme
  • Understand how themes work 

Regardless of your reasons for starting down this adventure, this handbook will help you take the next steps toward building a WordPress theme of your own.

Your skill level

While not a strict requirement, you will get the most out of this handbook if you have a baseline understanding and some experience with web technologies, such as HTML, CSS, and PHP. JavaScript knowledge would be a bonus if you plan to add interactivity to the front end.

Present-day WordPress and its block theme system allow you to customize and export a theme directly from the Site Editor interface:

WordPress Site Editor with the options menu dropdown open on the right. The Export option is highlighted.
Exporting a variation of the core Twenty Twenty-Three theme.

With each major WordPress update, its visual building tools become even more robust. Still, having some basic HTML, CSS, and PHP knowledge will help you move along faster.

Unlike block themes, classic themes are built entirely from code. This requires that you be comfortable enough to edit one or more of those languages to some degree.

The Reading this handbook page has more information on the prerequisite knowledge you need to build themes.

At the very least, you must be able to set up and configure a website using WordPress. Otherwise, you won’t be able to test or use the theme that you are building. You can learn more about getting things running in the Tools and setup documentation.

What this handbook covers

This handbook provides the basic information you need to build both block and classic WordPress themes. This includes in-depth coverage of the essential features and APIs that you should know, such as the topics in the Core Concepts chapter. It also dives into tools and techniques for building more advanced themes in the Advanced Topics chapter.

WordPress is a vast subject. HTML, CSS, PHP, accessibility, and other web technologies are even larger. It’d be impossible to cover every aspect of building a website in this handbook alone. Therefore, it is highly-focused on the fundamentals of theme building.

The goal of this handbook is to give you a solid foundation for WordPress theme creation by providing step-by-step instructions for building basic themes and providing resources to further your skills.

If this sounds like something you’d be interested in, come along. You’re in for a journey.