Taking advantage of settings.custom in theme.json #134
Replies: 2 comments
-
I'd also like to add that this is something I think about a lot when folks say, "You can't do X, Y, and Z in theme.json." Well, technically, you can. There's no UI piece to it for the end-user, but that's rarely one of the concerns in these conversations. I really just don't think we've fully explored how flexible what's already in core is. So, I'd really like for us to show off this feature in a way that gets folks to thinking beyond presumed limitations. |
Beta Was this translation helpful? Give feedback.
-
The topic has been approved. The discussion is now locked, |
Beta Was this translation helpful? Give feedback.
-
From this discussion on the Dev Blog: https://developer.wordpress.org/news/2023/05/customizing-core-block-style-variations-via-theme-json/
I'm wondering if many theme authors know how to utilize the
settings.custom
property intheme.json
and pair it with custom stylesheets.For example:
Produces these custom properties:
On its own, that's all it does. The exciting part is using these custom properties to do your own thing.
With the above example, I could style the
<code>
element (for inline code) like this in mystyle.css
:Why not just stick it all in your CSS file to start with?
Good question. A few reasons:
theme.json
./styles/{stylename}.json
files.theme.json
files in child themes.<code>
, it'd be simple to transfer the JSON code if/when core supports the element intheme.json
.Any other things you can do with it?
It's possible to couple this with Hybrid/Universal themes that use the customizer because you have access to these via PHP. For example, a classic/hybrid theme could set up custom color options in the customizer for users (they don't have Site Editor access, mind you). Then, override these via the PHP filter hooks.
In need of an example
The above was just a quick example, so I'm opening this up to discuss potential ideas to really show off this feature. The simple use case of customizing the
<code>
element could work, but let's think a little bigger.Beta Was this translation helpful? Give feedback.
All reactions