Support » Themes and Templates » Custom CSS for parent pages and children

  • Resolved RandiFTW

    (@randiftw)


    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) http://www.viewmonthealth.com

    Where I am trying to accomplish this:
    http://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 } elseif (is_page('pt')) { ?>
    		<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/viewmont-pt.css" type="text/css">
    	<?php } elseif (is_page('sleep')) { ?>
    		<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/viewmont-sleep.css" type="text/css">
    	<?php } elseif (is_page('primemed')) { ?>
    		<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/viewmont-primemed.css" type="text/css">
    	<?php } else { ?>
    		<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" />
    	<?php } ?>

    How can I do this?

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom CSS for parent pages and children’ is closed to new replies.