WordPress css to include a stylesheet

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”

Read More

So I created my home.php

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

Google is not helping?

Related posts

Leave a Reply

2 comments

  1. 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.