Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Alessandro Costa
Alessandro Costa
12,629 Points

how to change the background color of a widget

I'm coding a widget that allow to change the background color of the widget itself. I've included the jquery code into the widget-fields.php file, and now when the user clicks on the color picker it returns the hex value of the color inside a custom variable $background_color. The question is: how can I tell WordPress to add the background color style to the widget? I've used this code echo div style="background-color: '. $background_color .'" ; echo $before_widget;

in other words, I've added a custom <div> that contains the widget, but I don't think this method is correct...