Good Morning All,
I have created a different background and a few other images for certain pages within our site. Currently the below code is working well with the "kids" page on our site.
<body<?php if ( is_page(array('kids'))) {
echo ' class="kids" '; } ?>>
I am trying to figure out how to go about adding that same CSS to other pages"under" the kids page. So if you go to kids/block-party, how would I go about adding it to the code to call that special CSS?
I have tried the below
<body<?php if ( is_page(array('kids, kids/block-party'))) {
echo ' class="kids" '; } ?>>
the comma does not seem to register for some reason.
This is a wordpress run site.
Thanks
Another option is simply replacing
with
Then you can target it it via css as follows:
Where the ID is the ID of the page/parent-page you are targeting. This will keep your template clear of logic, and allow you the same customization options your current method is using.
Figured out i needed the ' ' around them
I may have over thought this one, but here's my solution.
The script below automatically gets all the children of a specific parent page and prints the class you need. This solution works great if you don't want to have to update the list of children pages manually.
This goes in your header.php file:
?>
Thanks, and I hope this helps!
Note: I know the 3 current answers are a common solution to this problem for WP, but in practice, I hate it. It produces bloated HTML and monolithic CSS :/
Answer: You could use a template file assigned to any number of pages to add specific CSS/Javascript like so:
Source: http://codex.wordpress.org/Function_Reference/wp_enqueue_script