1

I am using the twentyten default theme.

I want to change the look and feel of my homepage only. I have a stylesheet which does it "mystyle.css"

So I created my home.php

Is there any hooks that I can use to include a stylesheet?

Google is not helping?

2 Answers 2

3

The best way of doing this would be to use a child theme. Basically, you put your CSS as a separate file in a separate directory, and you have a child theme. That links to the parent theme's stylesheet to pull in its style, then overrides anything you want to override. That page I linked to has a complete example that will do what you need.

This has the advantage that if twentyten gets updated in the future, you'll pick up all the new twentyten fixes automatically, and your stylesheet overrides will still apply.

So, once you've got the child theme CSS file set up, it's just a matter of targeting the homepage only with your CSS, which is easy. Twentyten, like most themes, applies classes to the <body> of the page to indicate what kind of page it is. For example, my home page's <body> currently looks like this:

<body class="home blog logged-in"> 

...with the home class indicating that this is the homepage.

So, just target your CSS at elements by adding the "home" class specifier. For example, if you put this in your stylesheet:

body.home p { 
   font-weight: bold;
}

Then all paragraphs on the home page will be bold, but other pages won't be affected.

Sign up to request clarification or add additional context in comments.

Comments

1

if the solution Matt gave you isn't what you are looking for you can always use wp_enqueue_style()

read more at http://codex.wordpress.org/Function_Reference/wp_enqueue_style

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.