WordPress.org

Support

Support » Plugins and Hacks » Switching Stylesheets – HELP

Switching Stylesheets – HELP

  • Hey there, new-ish user here, using 1.0.2.
    I wanted to add a couple of links to my menu to pass a variable to PHP which would determine which stylesheet would load and then also cookie that value to keep it between sessions…
    However it doesn’t work so far and I thought I cry and ask for help… The page loads but the stylesheet selected doesn’t so you end up with unstyled content.
    Here is what I’ve done so far:
    At the very top of the page I put the cookie stuff:
    if ($sheetvar){
    setcookie ("StyleCookie", $sheetvar);
    } else if ($_COOKIE['StyleCookie']){
    $sheetvar = $_COOKIE['StyleCookie'];
    }else {
    $sheetvar = "standard-sans";
    }

    Then in the header I commented out the style sheet line and added…
    <?php
    switch ($sheetvar){
    case "standard-sans":
    print ("<style type=\"text/css\" media=\"screen\">
    @import url(\"$siteurl/wp-layout.css\")
    </style>");
    break;
    case "standard-sans2":
    print ("<style type=\"text/css\" media=\"screen\">
    @import url(\"$siteurl/wp-layout-ss2.css\")
    </style>");
    break;
    default:
    print ("<style type=\"text/css\" media=\"screen\">
    @import url(\"$siteurl/wp-layout.css\")
    </style>");
    break;
    }
    ?>

    And lastly in the menu code I put in this:
    <li id="other">

    Can anyone assist?
    The URL for the blog is http://bookofgeek.robstearn.com

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Switching Stylesheets – HELP’ is closed to new replies.
Skip to toolbar