OK, so here is the solution I applied:
1- In functions.php, I added this code near the top, right under:
//* Child theme (do not remove)
define( 'CHILD_THEME_NAME', 'Generate Theme' );
define( 'CHILD_THEME_URL', 'http://my.studiopress.com/themes/generate' );
define( 'CHILD_THEME_VERSION', '1.0.2' );
$content_width = apply_filters( 'content_width', 570, 450, 880 );
Here is the code I inserted:
//* Add custom body class to the head
add_filter( 'body_class', 'sp_body_class' );
function sp_body_class( $classes ) {
global $post;
if ( is_page( '4' ) || (isset($post->post_parent) && $post->post_parent == 4)){
$classes[] = 'educate-class';
}
if ( is_page( '12329' ) || (isset($post->post_parent) && $post->post_parent == 12329)){
$classes[] = 'advocate-class';
}
if ( is_page( '12330' ) || (isset($post->post_parent) && $post->post_parent == 12330)){
$classes[] = 'celebrate-class';
}
if ( is_page( '12331' ) || (isset($post->post_parent) && $post->post_parent == 12331)){
$classes[] = 'connect-class';
}
return $classes;
}
2- I created the 4 classes to insert in my style.css file AT THE VERY BOTTOM of the file, after everything (Generate theme has a double closing }, so right AFTER that). Here is what it looks like :
/* EDUCATE pages - different background */
.educate-class {
background: #84b855;
}
.educate-class #inner {
background-color: #84b855;
}
.educate-class #wrap {
background-color: #6a9544;
}
/* ADVOCATE pages - different background */
.advocate-class {
background: #f28c4d;
}
.advocate-class #inner {
background-color: #f28c4d;
}
.advocate-class #wrap {
background-color: #dc5b0b;
}
/* CELEBRATE pages - different background */
.celebrate-class {
background: #e09ddc;
}
.celebrate-class #inner {
background-color: #e09ddc;
}
.celebrate-class #wrap {
background-color: #cd66cc;
}
/* CONNECT pages - different background */
.connect-class {
background: #c2afe6;
}
.connect-class #inner {
background-color: #c2afe6;
}
.connect-class #wrap {
background-color: #673bb8;
}
3- I select the appropriate parent for each child-page in the dashboard, so they will display the specific color.
Voila! Hope this helps someone else, this is by far the simplest and most effective way I’ve seen of doing it.
Regards,
Andre
I hoped someone else may have ideas or knowledge to share, Elliot. I’ve been Googling for hours today, and following links to text and videos, but again, most of what I find assumes you are more advanced and know what files you need to edit and what settings need to be made. It’s part of the reality out there. So much time wasted on research to end up feeling worse about yourself than when you start… 🙂
Basically: can this plugin do what I’m trying to do? I would appreciate knowing.
Thanks again,
Andre
Thank you Elliot!
However, I’m not at that level of expertise yet, so all this is a bit blurry for me. I thought using the plugin would be straightforward, but I have never used custom fields.
If you have a step by step example I’d greatly appreciate. For example, how many modifications will I have to do altogether? How many files, dashboard settings, etc. And does this mean I won’t use the plugin?
Thanks again!
Regards,
Andre
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
🚨 The 2023 ACF Annual Survey closes tomorrow! This is your last chance to complete the survey and help guide the evolution of ACF. https://t.co/0cgr9ZFOJ5
— Advanced Custom Fields (@wp_acf) May 18, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.