You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that this field requires using [version 2 of theme.json](/docs/reference-guides/theme-json-reference/theme-json-living.md). The content creator will then find the respective Pattern in the inserter “Patterns” tab in the categories that match the categories from the Pattern Directory.
86
+
The content creator will then find the respective Pattern in the inserter “Patterns” tab in the categories that match the categories from the Pattern Directory.
Copy file name to clipboardexpand all lines: docs/how-to-guides/themes/global-settings-and-styles.md
+38-29
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Global Settings & Styles (theme.json)
2
2
3
-
WordPress 5.8 comes with [a new mechanism](https://make.wordpress.org/core/2021/06/25/introducing-theme-json-in-wordpress-5-8/) to configure the editor that enables a finer-grained control and introduces the first step in managing styles for future WordPress releases: the `theme.json` file. Then `theme.json`[evolved to a v2](https://make.wordpress.org/core/2022/01/08/updates-for-settings-styles-and-theme-json/) with WordPress 5.9 release. This page documents its format.
3
+
WordPress 5.8 comes with [a new mechanism](https://make.wordpress.org/core/2021/06/25/introducing-theme-json-in-wordpress-5-8/) to configure the editor that enables a finer-grained control and introduces the first step in managing styles for future WordPress releases: the `theme.json` file.
4
4
5
5
## Rationale
6
6
@@ -48,7 +48,7 @@ To address this need, we've started to experiment with CSS Custom Properties, ak
48
48
49
49
```json
50
50
{
51
-
"version": 2,
51
+
"version": 3,
52
52
"settings": {
53
53
"color": {
54
54
"palette": [
@@ -86,7 +86,7 @@ body {
86
86
87
87
```json
88
88
{
89
-
"version": 2,
89
+
"version": 3,
90
90
"settings": {
91
91
"custom": {
92
92
"line-height": {
@@ -115,7 +115,7 @@ This specification is the same for the three different origins that use this for
115
115
116
116
```json
117
117
{
118
-
"version": 2,
118
+
"version": 3,
119
119
"settings": {},
120
120
"styles": {},
121
121
"customTemplates": {},
@@ -125,10 +125,13 @@ This specification is the same for the three different origins that use this for
125
125
126
126
### Version
127
127
128
-
This field describes the format of the `theme.json` file. The current version is [v2](https://developer.wordpress.org/block-editor/reference-guides/theme-json-reference/theme-json-living/), [introduced in WordPress 5.9](https://make.wordpress.org/core/2022/01/08/updates-for-settings-styles-and-theme-json/). It also works with the current Gutenberg plugin.
128
+
This field describes the format of the `theme.json` file. The latest version is [version 3](https://developer.wordpress.org/block-editor/reference-guides/theme-json-reference/theme-json-living/)introduced in WordPress 6.6.
129
129
130
-
If you have used [v1](https://developer.wordpress.org/block-editor/reference-guides/theme-json-reference/theme-json-v1/) previously, you don’t need to update the version in the v1 file to v2, as it’ll be [migrated](https://developer.wordpress.org/block-editor/reference-guides/theme-json-reference/theme-json-migrations/) into v2 at runtime for you.
130
+
New versions are introduced when a breaking change needs to be made. This allows theme authors to choose when to opt-in to the breaking changes and migrate their theme.json files to the new format.
131
131
132
+
Older versions of `theme.json` are backwards-compatible and will continue to work with newer versions of WordPress and the Gutenberg plugin. However new features will be developed on the latest version.
133
+
134
+
Follow the instructions in [migrating to newer versions](https://developer.wordpress.org/block-editor/reference-guides/theme-json-reference/theme-json-migrations/) for details on updating to the latest version.
132
135
133
136
### Settings
134
137
@@ -145,7 +148,7 @@ The settings section has the following structure:
145
148
146
149
```json
147
150
{
148
-
"version": 2,
151
+
"version": 3,
149
152
"settings": {
150
153
"border": {
151
154
"radius": false,
@@ -209,7 +212,7 @@ The settings section has the following structure:
209
212
210
213
```json
211
214
{
212
-
"version": 2,
215
+
"version": 3,
213
216
"settings": {
214
217
"appearanceTools": false,
215
218
"border": {
@@ -357,7 +360,7 @@ The naming schema for the classes and the custom properties is as follows:
357
360
358
361
```json
359
362
{
360
-
"version": 2,
363
+
"version": 3,
361
364
"settings": {
362
365
"color": {
363
366
"duotone": [
@@ -532,7 +535,7 @@ For example:
532
535
533
536
```json
534
537
{
535
-
"version": 2,
538
+
"version": 3,
536
539
"settings": {
537
540
"custom": {
538
541
"baseFont": 16,
@@ -577,7 +580,7 @@ Note that the name of the variable is created by adding `--` in between each nes
577
580
578
581
```json
579
582
{
580
-
"version": 2,
583
+
"version": 3,
581
584
"settings": {
582
585
"color": {
583
586
"custom": false
@@ -597,7 +600,7 @@ Note that the name of the variable is created by adding `--` in between each nes
597
600
598
601
```json
599
602
{
600
-
"version": 2,
603
+
"version": 3,
601
604
"settings": {
602
605
"blocks": {
603
606
"core/button": {
@@ -614,7 +617,7 @@ Note that the name of the variable is created by adding `--` in between each nes
614
617
615
618
```json
616
619
{
617
-
"version": 2,
620
+
"version": 3,
618
621
"settings": {
619
622
"color": {
620
623
"palette": [
@@ -682,7 +685,7 @@ Each block declares which style properties it exposes via the [block supports me
682
685
683
686
```json
684
687
{
685
-
"version": 2,
688
+
"version": 3,
686
689
"styles": {
687
690
"border": {
688
691
"radius": "value",
@@ -761,7 +764,7 @@ Each block declares which style properties it exposes via the [block supports me
761
764
762
765
```json
763
766
{
764
-
"version": 2,
767
+
"version": 3,
765
768
"styles": {
766
769
"border": {
767
770
"color": "value",
@@ -856,7 +859,7 @@ Styles found at the top-level will be enqueued using the `body` selector.
856
859
857
860
```json
858
861
{
859
-
"version": 1,
862
+
"version": 3,
860
863
"styles": {
861
864
"color": {
862
865
"text": "var(--wp--preset--color--primary)"
@@ -885,7 +888,7 @@ By default, the block selector is generated based on its name such as `.wp-block
885
888
886
889
```json
887
890
{
888
-
"version": 1,
891
+
"version": 3,
889
892
"styles": {
890
893
"color": {
891
894
"text": "var(--wp--preset--color--primary)"
@@ -972,7 +975,7 @@ If they're found in the top-level the element selector will be used. If they're
@@ -1066,7 +1069,7 @@ For example, this is how to provide styles for the existing `plain` variation fo
1066
1069
1067
1070
```json
1068
1071
{
1069
-
"version": 2,
1072
+
"version": 3,
1070
1073
"styles":{
1071
1074
"blocks": {
1072
1075
"core/quote": {
@@ -1103,7 +1106,7 @@ Within this field themes can list the custom templates present in the `templates
1103
1106
1104
1107
```json
1105
1108
{
1106
-
"version": 2,
1109
+
"version": 3,
1107
1110
"customTemplates": [
1108
1111
{
1109
1112
"name": "my-custom-template",
@@ -1132,7 +1135,7 @@ Currently block variations exist for "header" and "footer" values of the area te
1132
1135
1133
1136
```json
1134
1137
{
1135
-
"version": 2,
1138
+
"version": 3,
1136
1139
"templateParts": [
1137
1140
{
1138
1141
"name": "my-template-part",
@@ -1145,22 +1148,28 @@ Currently block variations exist for "header" and "footer" values of the area te
1145
1148
1146
1149
### patterns
1147
1150
1148
-
<divclass="callout callout-alert">Supported in WordPress from version 6.0 using <ahref="https://developer.wordpress.org/block-editor/reference-guides/theme-json-reference/theme-json-living/">version 2</a> of <code>theme.json</code>.</div>
1151
+
<divclass="callout callout-alert">Supported in WordPress from version 6.0.</div>
1149
1152
1150
1153
Within this field themes can list patterns to register from [Pattern Directory](https://wordpress.org/patterns/). The `patterns` field is an array of pattern `slugs` from the Pattern Directory. Pattern slugs can be extracted by the `url` in single pattern view at the Pattern Directory. For example in this url `https://wordpress.org/patterns/pattern/partner-logos` the slug is `partner-logos`.
It can be difficult to remember the theme.json settings and properties while you develop, so a JSON scheme was created to help. The schema is available at https://schemas.wp.org/trunk/theme.json
1164
+
It can be difficult to remember the theme.json settings and properties and which versions of WordPress support which settings while you develop, so it can be helpful to use the provided JSON schema for theme.json.
1165
+
1166
+
Many code editors support JSON schema and can provide help like tooltips, autocomplete, or schema validation right in your editor.
1167
+
1168
+
Theme.json schemas for each WordPress version are available at `https://schemas.wp.org/wp/{{version}}/theme.json`. For example a schema for WordPress 5.8 is available at `https://schemas.wp.org/wp/5.8/theme.json`. To ensure that you're only using features available to your users, it's best to use the oldest version that your theme supports.
1169
+
1170
+
The latest schema including all the latest changes from the Gutenberg plugin is available at `https://schemas.wp.org/trunk/theme.json`.
1162
1171
1163
-
Code editors can pick up the schema and can provide help like tooltips, autocomplete, or schema validation in the editor. To use the schema in Visual Studio Code, add `"$schema": "https://schemas.wp.org/trunk/theme.json"`to the beginning of your theme.json file.
1172
+
Check your editor's documentation for JSON schema support. In Visual Studio Code, for example, you need to add `"$schema": "https://schemas.wp.org/wp/x.x/theme.json"`as a top-level property of your theme.json file, but other editors may be configured differently.
1164
1173
1165
1174

1166
1175
@@ -1210,7 +1219,7 @@ For example:
1210
1219
1211
1220
```json
1212
1221
{
1213
-
"version": 2,
1222
+
"version": 3,
1214
1223
"settings": {
1215
1224
"custom": {
1216
1225
"lineHeight": {
@@ -1240,7 +1249,7 @@ A few notes about this process:
1240
1249
1241
1250
```json
1242
1251
{
1243
-
"version": 2,
1252
+
"version": 3,
1244
1253
"settings": {
1245
1254
"custom": {
1246
1255
"line--height": { // DO NOT DO THIS
@@ -1284,7 +1293,7 @@ body {
1284
1293
1285
1294
### Specificity for link colors provided by the user
1286
1295
1287
-
In v1, when a user selected a link color for a specific block we attached a class to that block in the form of `.wp-element-<ID>` and then enqueued the following style:
1296
+
In WordPress 5.8, when a user selected a link color for a specific block we attached a class to that block in the form of `.wp-element-<ID>` and then enqueued the following style:
Copy file name to clipboardexpand all lines: docs/reference-guides/theme-json-reference/README.md
+2-1
Original file line number
Diff line number
Diff line change
@@ -2,9 +2,10 @@
2
2
3
3
This reference guide lists the settings and style properties defined in the theme.json schema. See the [theme.json how to guide](/docs/how-to-guides/themes/global-settings-and-styles.md) for examples and guide on how to use the theme.json file in your theme.
0 commit comments