stylesheet not importing in wordpress

I was just going through this tutorial HERE and basically the author recommends that the css stylesheet be imported like so:

function theme_enqueue_styles() {
wp_register_style( 'custom-style', get_template_directory_uri() . '/style.css', array(), '20120208', 'all' );
wp_enqueue_style('custom-style' );

}

Read More

add_action( ‘wp_enqueue_scripts’, ‘theme_enqueue_styles’ );

add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );

My header.php of my theme looks like so:

<!doctype html>
<html <?php  language_attributes(); ?> >
    <head>
        <meta charset="<?php  bloginfo('charset');   ?>">
        <meta http-equiv="x-ua-compatible" content="ie=edge">
        <title><?php bloginfo('name');  ?></title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="shortcut icon" type="image/x-icon" href="favicon.ico">        

        <?php  wp_head(); ?>

    </head>
    <body <?php  body_class(); ?>>



    <header class="site-header">
        <h1><a href="<?php echo home_url(); ?>"></a><?php bloginfo('name');  ?></h1>
        <h5><?php bloginfo('description'); ?></h5>
    </header>

But i am still not seeing the effect of my stylesheet , can anybody point me to what exactly am i doing wrong ?

EDIT:: On further inspection i found out that if i post the contents of header.php in index.php the stylesheet is loading fine , which means that my functions.php files is working fine. So i guess the problem is with my header.php file, I have updated above what my header.php file looks like, so can somebody tell me whats wrong with my header.php file now ?

Thank you.

Related posts

4 comments

  1. add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
    function theme_enqueue_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    }
    
  2. It should be:

        add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
        function theme_enqueue_styles() {
            wp_register_style( 'custom-style', get_template_directory() . '/style.css');
            wp_enqueue_style('custom-style' );
        }
    

    The style.css is in your root folder of the theme, am I right?

  3. add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
    function theme_enqueue_styles() {
    wp_register_style( 'parent-style', get_template_directory_uri() . '/styles.css', array(), false, 'screen' );
     wp_enqueue_style( 'parent-style' );
    }
    

Comments are closed.