主题开发文档

全局设置与样式(theme.json)

💡 云策文档标注

概述

本文档介绍如何通过 theme.json 文件配置 WordPress 主题的全局设置和样式,涵盖从基础概念到高级功能的全面指南,适用于初学者和有经验的开发者。

关键要点

  • theme.json 是块主题的基础文件,用于配置颜色、排版等全局设置和样式。
  • 文档提供结构化学习路径,包括主题设置、样式应用、自定义模板和模板部件等核心主题。
  • 支持自定义设置、样式变体和模式捆绑,增强主题的灵活性和用户体验。

📄 原文内容

Welcome to the Global Settings and Styles documentation. In this chapter you will learn everything you need to know about configuring settings, styles, and more via your theme’s theme.json file.

theme.json is a foundational piece of block theming. While it is not a strictly required file, you will need to work with it for nearly any theme project. It is useful for everything from configuring colors to defining default typography settings to applying front-end styles to your theme.

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 the ins-and-outs of theme.json for first-time themers. 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 theme.json: A walkthrough of setting up your theme.json file, introducing you to the foundational concepts for configuring global settings and styles for your theme.
  • Settings: Documentation for each of the standard and custom settings that you can configure via theme.json. Sub-pages document every available setting.
  • Styles: Learn how to use the standard design system to apply styles through theme.json, which also integrate with the user interface.
  • Custom Templates: How to register custom post, page, and CPT (custom post type) templates for your theme.
  • Template Parts: How to register custom template parts that can be reused across your theme.
  • Patterns: How to bundle patterns from the official patterns repository with your theme.
  • Style Variations: Documentation on creating custom theme.json style variations, giving your users alternative designs to choose from.