admin管理员组文章数量:1290950
I added custom colors to my functions.php
file:
functions.php
add_theme_support( 'editor-color-palette', array(
array(
'name' => __( 'Blue'),
'slug' => 'blue',
'color' => '#00548F',
),
viewing the source in editor:
"backgroundColor\":\"blue\"...
<div class=\"wp-block-columns alignfull event-block has-blue-background-color has-background\">
and finally in the page inspector:
<div class="wp-block-columns alignfull event-block has-blue-background-color has-background">
Not surprisingly, the Rules or Computed Values show zero background attributes.
I tried it in another of my themes (both are hand-rolled) and the same result. When I loaded up the twenty-nineteen theme, it worked.
Is there some function, callback, file that is needed to make this work that I might have errantly deletely?
Thanks.
I added custom colors to my functions.php
file:
functions.php
add_theme_support( 'editor-color-palette', array(
array(
'name' => __( 'Blue'),
'slug' => 'blue',
'color' => '#00548F',
),
viewing the source in editor:
"backgroundColor\":\"blue\"...
<div class=\"wp-block-columns alignfull event-block has-blue-background-color has-background\">
and finally in the page inspector:
<div class="wp-block-columns alignfull event-block has-blue-background-color has-background">
Not surprisingly, the Rules or Computed Values show zero background attributes.
I tried it in another of my themes (both are hand-rolled) and the same result. When I loaded up the twenty-nineteen theme, it worked.
Is there some function, callback, file that is needed to make this work that I might have errantly deletely?
Thanks.
Share Improve this question asked Jun 9, 2021 at 14:39 breadwildbreadwild 3915 silver badges22 bronze badges1 Answer
Reset to default 3If you're adding theme support for editor-color-palette
then you need to add styles for those colours to your stylesheet. As documented:
Themes are responsible for creating the classes that apply the colors in different contexts. Core blocks use “color” and “background-color” contexts. So to correctly apply “strong magenta” to all contexts of core blocks a theme should implement the following classes:
.has-strong-magenta-background-color { background-color: #313131; } .has-strong-magenta-color { color: #f78da7; }
The class name is built appending ‘has-‘, followed by the class name using kebab case and ending with the context name.
本文标签: Block background color not appearing on site
版权声明:本文标题:Block background color not appearing on site 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741515263a2382847.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论