0
<?php

/*
# =======================================
# functions.php
#
# The theme's Function
# =======================================

*/

/*---------------------------------------*/
/* 1. CONSTANTS */
/*---------------------------------------*/

define('THEMEROOT', get_stylesheet_directory_uri());
define('IMAGES', THEMEROOT.'/img');
define('JS', THEMEROOT.'/js');


/*---------------------------------------*/
/* 2. SCRIPTS */
/*---------------------------------------*/
if(!function_exists('hydrogen_scripts')) {
    function hydrogen_scripts () {

        /* Load the stylesheets. */
        wp_enqueue_style( 'style', THEMEROOT . 'style.css' );
    }
    add_action('wp_enqueue_scripts', 'hydrogen_scripts');

}

What mistake am I doing that this is not able to load the style.css? Any idea? Looks like some subtle mistake that is not visible.

  • Glad to hear, thanks! Not sure about the downvote. Remembering what functions do/don't return a trailing slash can be tricky. There is a function called trailingslashit( $string ) which will add a trailing slash if $string does not already have one. – Dave Romsey Jan 19 '17 at 4:54
0

The URL returned by get_stylesheet_directory_uri() does not have a slash, so you need to add one .E.g.:

wp_enqueue_style( 'style', THEMEROOT . '/style.css' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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