tags:

views:

27

answers:

2

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

+2  A: 

Figured out i needed the ' ' around them

<body<?php if ( is_page(array('newsletter-1', 'newsletter-2', 'newsletter-3'))) { echo '   class="myclass" '; } ?>>
Matthew Snider
+2  A: 

Another option is simply replacing

<body>

with

<body <?php body_class(); ?>>

Then you can target it it via css as follows:

body.page-id-2, body.parent-pageid-2 { background-color: red; }

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.

Jervis
Thanks for that, I may end up using that code instead.
Matthew Snider