开发者

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.c开发者_Python百科ss"

So I created my home.php

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

Google is not helping?


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜