Support » Fixing WordPress » Can’t get 2 style sheets to work – Have tried everything

  • Resolved TinaHunter

    (@tinahunter)


    Alright. I’ve been trying for almost a week from gleaning information off this forum but now I need to ask directly.

    I have customized/created two Style Sheets (style.css -default, and widesidebar.css). I also have two page templates (page.php – default and page2.php).

    I have edited the header.php of my theme “Wilderness” so that under the 1st “Link Rel” section it reads:

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

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

    Thus far my entire site is still using the default style sheet, I tried using my “About” page as an example (changing the page template used when editing the page in WP write section) to use the other style sheet but nothing has changed.

    Questions: – Is the code wrong? Have I missed a step?
    – Should I be trying to use (is_page(‘about’) (for example) instead?

    Any help would be fantastic!!!!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Try:

    <?php
    if ( is_page_template('page2.php)) { ?>
    <link rel=”stylesheet” type=”text/css” href=”<?php bloginfo(‘template_directory’); ?>/widesidebar.css” />
    <?php } else { ?>
    <link rel=”stylesheet” type=”text/css” href=”<?php bloginfo(‘template_directory’); ?>/style.css” />
    <?php } ?>

    [lowercased the filename and added in missing opening php statement and closing curly bracket]

    Thread Starter TinaHunter

    (@tinahunter)

    Thank you for responding.

    However, when I enter in the text above I get an error message:

    Parse error: syntax error, unexpected T_STRING in /home/NAME/public_html/wp-content/themes/Wilderness/header.php on line 23

    Can you tell me what might be going wrong?

    Thanks so much

    Can you tell me what might be going wrong?

    Most obvious are a missing quote and fancy quotes in the pasted code samples. Use plain keyboard quotes ( ‘ ” ) instead of fancy quotes ( ‘ ” ) in code.

    Thread Starter TinaHunter

    (@tinahunter)

    Ok. No error this time, but it’s still not working. All my pages are showing up using the default page template and style sheet.

    More Info Maybe?

    I’ve altered the size of the sidebar from the original style sheet. It was two sidebars. I have made it one side bar with two sizes (thin and wide (like the two sidebars width)). I changed the default style sheet to reflect the thin sidebar. Widesidebar.css is for the wide sidebar.

    I created a second page template that is no different except:

    <?php
    /*
    Template Name: Page Template 2
    */
    ?>

    I did this because from what I could glean from the other forum forum posts this was the only way to get only certain pages to use the widesidebar style sheet.

    Please help.

    Am I doing something wrong?

    Thread Starter TinaHunter

    (@tinahunter)

    bump

    Thread Starter TinaHunter

    (@tinahunter)

    Bump!

    Anyone?

    Have a look at your page with Firefox addon called Firebug, it will show you on the right side which stylesheet is used for specific divs and maybe you will see where’s the problem.
    Also consider that some css style rules may come from template itself so in this case you sometimes have to define your css in external stylesheets with !important value, e.g. #sidebar{color: red !important;}

    Thread Starter TinaHunter

    (@tinahunter)

    Alright.

    So I downloaded Firebug and it told me that all pages where using the default stylesheet it also showed me that the “link rel” section above where I put in the PHP code above was linking directly to the default stylesheet and effectively cancelling out the code below calling two style sheets.

    So I copied everything from the header.php and pasted it into the page2.php template (making sure to delete the call to get_header). Then I changed the “link rel” section to call the new stylesheet and deleted the php code from both the original header and the page template header section.

    And it worked. I now have two page templates working.

    Thanks Tastic for the hint on Firebug.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Can’t get 2 style sheets to work – Have tried everything’ is closed to new replies.