WordPress.org

Ready to get started?Download WordPress

Forums

Static Page style sheets (6 posts)

  1. stephenolson
    Member
    Posted 7 years ago #

    I'm having some difficulty trying to call different style sheets for different individual static WordPress "Pages".

    I have this code in my header:

    <style type="text/css" media="screen">
    /* Calls the style sheets for each category */
    <?php
    $post = $wp_query->post;
    
    if ( in_category('1') ) {
    include(TEMPLATEPATH . '/assignments.css');
    
    } elseif ( in_category('2') ) {
    include(TEMPLATEPATH . '/television.css');
    
    } elseif ( in_category('9') ) {
    include(TEMPLATEPATH . '/workfromhome.css');
    
    } elseif ( is_page('338') ) {
    include(TEMPLATEPATH . '/television.css');
    
    } elseif ( in_category('7') ) {
    include(TEMPLATEPATH . '/clickables.css');
    
    }
    
    ?>
    </style>

    That works for categories, but not for static pages. It used to though. Could this be permalink related?

    thanks!

  2. Glenn Ansley
    Member
    Posted 7 years ago #

  3. stephenolson
    Member
    Posted 7 years ago #

    Okay, so I know how to call different page templates through the wordpress backend, but how do i have those templates call different style sheets. I want all of the page templates to have the same structure, only with different backgrounds...

  4. Glenn Ansley
    Member
    Posted 7 years ago #

    That's the great thing about CSS... it's cascading. This means that if you place CSS on a page, it will overide the external style.css.

    Use the following code with page templates or a conditional statement (in the template, not the style.css):

    <style type="text/css">
    %div% {
    background: #ffffff url('%image_folder&/%image_name.jpg') no-repeat top left;
    }
    </style>
  5. stephenolson
    Member
    Posted 7 years ago #

    Awesome, thanks so much for your help!

  6. Glenn Ansley
    Member
    Posted 7 years ago #

    So it's working? Great!

Topic Closed

This topic has been closed to new replies.

About this Topic