Custom CSS on WordPress parent and child pages

Believe me, I have searched for an answer to this for several days straight. I believe the answer is simple but I can’t get it to work. I’ll try to be as specific as possible.

I’ve learned how to set css for specific WordPress pages, however what I need to set CSS for WordPress parent pages and their children. While it can be accomplished by including every page to my code I know that there has to be a more efficient way as I have about 20 pages under each parent page.

An example of what I am looking for can be found here: (original site) www.viewmonthealth.com

Where I am trying to accomplish this: www.notthemama.net/prime/

Each main link leads to a different section with separate css.

Here is what I have:

<?php if (is_page('imaging')) { ?>
    <link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/viewmont-imaging.css" type="text/css">
<?php } elseif (is_page('labs')) { ?>
    <link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/viewmont-labs.css" type="text/css">
<?php } else { ?>
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" />
<?php } ?>

This works perfectly for pages. I just need to include the parent pages (what I have now) AND child pages (imaging/forms.php). How can I do this? Any help is appreciated! 😀

Leave a Comment