WordPress.org

Forums

[resolved] Custom CSS for parent pages and children (4 posts)

  1. RandiFTW
    Member
    Posted 3 years ago #

    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?

  2. zeaks
    Member
    Posted 3 years ago #

    Usually themes have a body class for each page http://codex.wordpress.org/Function_Reference/body_class and conditional CSS can be used to target specific pages or types of pages. I don't see any body classes for your theme though.

  3. RandiFTW
    Member
    Posted 3 years ago #

    Okay, that makes sense.
    How do I set a body tag for EACH page?

  4. RandiFTW
    Member
    Posted 3 years ago #

    Nevermind, I was able to find help for this elsewhere. Someone sent me here and it worked perfectly for what I needed.

    Thanks, anyway. :D

Topic Closed

This topic has been closed to new replies.

About this Topic