Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have recently started to learn WordPress and after learning how to use it at basic level I immediately started to learn how to develop templates since this is what interested me from the start when I started to learn it.

I am reading WordPress 3 Complete and at Chapter 6 the book guides you to develop your first basic theme. The only problem is that it seems that my theme is not taking the style sheet. I have tried to use:

<link rel="stylesheet" type="text/css" href="style.css"/> 

and

<style type="text/css">@import url("style.css");</style>

None of them seem to get the style on the page. What should I do?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

You have to make sure WordPress finds the directory where your theme is. There is a useful function doing all the work for you: bloginfo().

<link rel="stylesheet" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
share|improve this answer
    
Thank you that did the trick –  Nistor Alexandru Jul 25 '12 at 9:24

Alternately, you can enqueue the style in your functions.php file (this is my new preference):

wp_enqueue_style( 'style_css', get_stylesheet_uri(), false );
share|improve this answer
    
I think I agree with you ... but is it the best method for theme developers? –  Damien Jul 25 '12 at 19:31
    
@damien, I can swear that there was either a WordPress idea or trac ticket where people were debating whether to start doing this with the WordPress "core" themes (the Twenty ___ ones), but now I can't find it. If everyone enqueued it with the 'style' $handle then it would be easy to use that handle with child themes or plugins. –  mrwweb Jul 25 '12 at 20:03
    
Thing is ... IMHO theme developers want to know HTML CSS and JS so a basic function like wp_enqueue_style might be too technical so you end up with <link rel .... –  Damien Jul 25 '12 at 21:04
1  
(This should really be in a chat. Sorry.) I've got to say that at this point you HAVE to be able to at least read basic PHP to do real, responsible theme development. If you want to use jQuery UI, for instance, you have to use wp_enqueue_style as well. So I think it's not an issue to use it one more time. –  mrwweb Jul 25 '12 at 21:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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