Dynamic Site Background Color (External vs Inline Style Sheet)

Hello :slight_smile:

Lets say I have CPT and I want the client to be able to set the Site Background Color.

Ive created a new Theme Style in Bricks, applied the correct conditions and set the Site Background Color to dynamic.

Under Bricks > Settings > Performance > CSS loading method

  • Inline works perfectly.
  • External, it falls over. No background color is set.

Should I try a different approach?

1 Like

Hey, did you figure it out?

Hello

Couple of options - since this post Bricks now offers the following page settings that accepts Dynamic Data (ACF)

OR

Utilize the ‘bricks/body/attributes’
@ Filter: bricks/body/attributes – Bricks Academy

add_filter( ‘bricks/body/attributes’, function( $attributes ) {

}

Inside you could you apply a style or class to body HTML tag which is obtain through ACF as an example
$attributes[‘class’] = ‘bg-color’;
$attributes[‘style’] = ‘background-color:’.$post_bg_color.‘’;

I specifically use the Filter and apply $attributes[‘style’] = ‘background-color:’.$post_bg_color.‘’;

I also use inline styles these days.

1 Like