0

Any tips or tricks on how to get a website to show a different stylesheet when you click on a menu item? What I want is one link to load a green css style and the other links keep the default style sheet. I am using U-Design.

Thanks in a advance!

2
  • are you talking about changing the style in the current page or load diferent pages with diferent styles? – Tomás Cot Sep 16 '14 at 18:57
  • Loading a different page with a different style. So when you click on Green it changes to a green style sheet. – curthayman Sep 16 '14 at 19:26
0

You have to use Conditional Tags, with those, you can check in which page you are, and load a diferent stylesheet for each option.

A little example using is_page

if(is_page('about')){

echo '<link href="style1.css" rel="stylesheet" type="text/css" />';
} else {
echo '<link href="style.css" rel="stylesheet" type="text/css" />';
}

That should go in your header.php file, or you could create diferent headers for diferent pages, and then use the get_header function. There are other ways to deal with headers, but that's a diferent topic.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.