Make Theme Colours Dynamic with ACF, CSS and php

Enable background and text colour changes within your template using Advanced Custom fields.

Place CSS markup within your template in the header area, and use the ID of the post or page where the fields are placed to make the CSS trigger on all pages (if they are universal).

<style>
.body {background: <?php the_field('colour', 2); ?>!important;} /* 2 is the page id */
.body a {color: <?php the_field('background_colour', 2); ?>!important;}/* 2 is the page id */
</style>

Leave a Reply

katherine as a flat graphic icon

About Me

I’m an African / Ojibwe First Nations Web Developer living in Winnipeg, Manitoba.

Visit the Tips and Blog to see what I’m working on.