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 the following code in my functions.php file with a call in the header, but nothing is being outputted in the html. There are no stylesheets.

I have tried that add action wp_enque_styles with and without the s (style)

<?php
function scripts_and_styles() {
  if (!is_admin()) {
  // normalize
    wp_register_style( 'normal-stylesheet', get_stylesheet_directory_uri() . 'http://necolas.github.com/normalize.css/2.1.0/normalize.css', array(), '', 'all' );
  // register main stylesheet
    wp_register_style( 'main-stylesheet', get_stylesheet_directory_uri() . '/css/style.css', array(), '', 'all' );

  // enqueue styles and scripts
    wp_enqueue_style( 'main-stylesheet' );
    wp_enqueue_style( 'normal-stylesheet' );
   }
 }
 add_action( 'wp_enqueue_styles', 'scripts_and_styles' ); 
?>
share|improve this question
    
never mind figured out I had to use wp_enque_scripts, why is this? –  Anders Kitson Feb 11 '13 at 2:00
1  
So is this question still open or not? And please pay more attention to your question titles. Trying to … is not a good title. –  toscho Feb 11 '13 at 2:32
1  
"I had to use wp_enque_scripts" - Because there is no analogous hook, wp_enqueue_styles (yet). –  Chip Bennett Feb 11 '13 at 4:21
    
it's also worth noting, if you're doing everything in a single action and not conditionally enqueueing things, you don't need to register then enqueue, you can pass all the same arguments to enqueue and skip registering them. –  Milo Feb 11 '13 at 15:18
add comment

3 Answers

You need to use the correct hook.

Currently, WordPress has a hook for enqueueing scripts: wp_enqueue_scripts, but does not have an analogous hook for enqueueing stylesheets, such as wp_enqueue_styles.

So, for the time-being, hook your stylesheet-enqueueing callback into wp_enqueue_scripts.

share|improve this answer
add comment
<?php
function scripts_and_styles() {
  if (!is_admin()) {
  // normalize
    wp_register_style( 'normal-stylesheet', 'http://necolas.github.com/normalize.css/2.1.0/normalize.css');
  // register main stylesheet
    wp_register_style( 'main-stylesheet', get_stylesheet_directory_uri() . '/css/style.css', array(), '', 'all' );

  // enqueue styles and scripts
    wp_enqueue_style( 'main-stylesheet' );
    wp_enqueue_style( 'normal-stylesheet' );
   }
 }
 add_action( 'wp_enqueue_scripts', 'scripts_and_styles' ); 
?>
share|improve this answer
add comment

Here is a Working Example on how to do it

// Create action hook to call the related function
add_action('wp_enque_scripts', 'register_my_style');

// Create the function to be included in the action hook above
function register_my_style() {

// Register your style
wp_register_style('my_css_style', plugins_url('/plugin_directory_name/css/mystyle.css/'));

//enque it after registered
wp_enque_style('my_css_style');
}

Please see the reference here http://codex.wordpress.org/Function_Reference/wp_register_style

share|improve this answer
add comment

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.