This code adds a color picker to the Edit Category screen which enables you to change colors for different elements on single posts in each category.
This code has been written in response to the following question from a registered user :
“I was hoping to be able to use the color picker and set a color per category that would populate across the site within the dashboard, so my clients could set the colors.”
Let’s take a look at what this solution gives you in the demo video.
Demo Video
Shows how you can use the color picker on every Edit Category screen to change the colors of different elements on single posts in that category. In this example, the color picker sets the colors for the entry title & entry meta however you can use it to set colors of any/all single post elements.
Installation Steps
There’s 2 steps :
# Step 1 – From the download folder, copy & paste the PHP code to the end of your child themes functions.php file.
Register or login to access the code in the download folder.
# Step 2 – Create a new field like this using ACF Pro :
Hi Brad,
How would I modify this code to work on the front page blog section? It’s already working beautifully on the archive pages, but changing this line
if ( is_singular( ‘post’ ) || is_category() ) {
to
if( is_home() || is_singular( ‘post’ ) || is_category() || is_archive() ) {
does work, BUT it adds this error to my portfolio page
Warning: array_pop() expects parameter 1 to be array, boolean given in
wp-content/themes/Hello Sassafras/functions.php on line 815
Line 815 is
$term = array_pop( $terms );
Apologize in advance if it’s a silly mistake. I’ve been trying to wrap my head around PHP, but I’m seriously struggling with it.
Thanks.
-Tatiana
website is http://mythandmagic.net
If you don’t need this functionality on CPT archives, you can add this check
You’ll also need to add inline CSS to the PHP. Something like this :
And change the ACF Pro > Field Groups > Location settings.
get_the_terms does return false sometimes so i’ll add a check and update the code in the download folder.
Thank you! This is exactly what I needed. Appreciate your help!