Support » Themes and Templates » Attaching different css styles to different page templates. Please help!

  • I apologize if this is duplicating someone else’s question, but I have been going in circles to figure this out and have not found the answer yet…

    Situation: I have created several different page templates to attach to different pages, using the Classic WP Theme. I am only using static pages, no posts. These pages are extremely stripped down, with no sidebar, no header or footer images or links, etc. Just the content of the page.
    * The only difference between each of the templates is going to be the background color and potentially text color. There will be about 10 of these pages/templates.

    Question: I need to know which tags I should be using in the template files and which css selectors I should be using to refer to those tags in the style sheet to address the different styles assigned to each template page.
    I understand the documentation on templates, tags, css, etc. but apparently I’m missing something since I can’t get it to work out.

    If someone would be so kind as to explain to me this process, I would greatly appreciate it.
    Many thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • tigtog

    (@tigtoggmailcom)

    The only way that I know is to add code to the header so that it fetches a different .css file depending on the page template.

    e.g.
    Just after this line in your header.php file

    ******************************************************************
    <link rel=”stylesheet” href=”<?php bloginfo(‘stylesheet_url’); ?>” type=”text/css” media=”screen” />
    ******************************************************************

    insert this snippet (adjusting for each page template that you have)

    *******************************************************************
    <?php
    if ( is_page_template(‘my_new_template.php’)) { ?>
    <link rel=”stylesheet” type=”text/css” href=”<?php bloginfo(‘template_directory’); ?>/my_new_template.css” />
    <?php } ?>
    *******************************************************************

    I saw this somewhere on the forums here, but I can’t find the link to give credit to the code author, sorry.

    Generic WordPress Body Tag

    <body id=”<?php echo the_slug(); ?>”<?php global $post; if (is_front_page()) {echo “>”;} else {?> class=”sub”>

    That worked great thank you

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Attaching different css styles to different page templates. Please help!’ is closed to new replies.