I've searched online and have not been able to find any answers to this one. I am in the middle of developing a new website and have started trying to work with the new theme.json feature in WordPress 5.8.
I've had no problems setting the layout width and defining a color pallette, however, when it then comes to setting a custom font family the editor doesn't seem to pick this up.
I have enqueued the custom Google font:
function prefix_block_styles() { wp_enqueue_style( 'prefix-editor-font', '//fonts.googleapis.com/css2?family=Ubuntu:wght@300;400;500;700&display=swap'); } add_action( 'enqueue_block_editor_assets', 'prefix_block_styles' ); And then I have this as my current theme.json:
{ "version":1, "settings": { "typography": { "fontFamilies": [ { "fontFamily": "Helvetica Neue, Helvetica, Arial, sans-serif", "slug": "helvetica-arial", "name": "Helvetica or Arial" }, { "fontFamily": "\"Ubuntu\", sans-serif", "slug": "ubuntu-sansserif", "name": "Ubuntu" } ] }, "layout": { "contentSize": "1600px", "wideSize": "1600px" } } } When I then refresh the editor, it still loads in serif.
Does anyone know what I am doing wrong here?
Thanks
theme.jsonfile is indeed being loaded correctly? (Did you put it inwp-content/themes/your-theme/theme.json?) And are you saying thelayoutoption works properly, but not thefontFamiliesoption? Have you tried clearing your caches? Have you double-checked that the Google font is also being loaded correctly?layoutoptions are working and I have also been able to addcoloroptions with no problems, it's only thefontFamilyoption that doesn't seem to work. I checked the source code and the Google font is being loaded. I have also cleared the cache.