0
votes

For some reason, this code in my functions.php file isn't working for my custom Wordpress Theme:

<?php 
add_theme_support('menus');

function mySite_scripts(){
 wp_enqueue_style('test', get_template_directory_uri() . '/base.css');
}

 add_action('wp_enqueue_scripts','mySite_scripts');
?>

My Theme is located in the wp-content/themes/mySite/css folder and is called base.css but when I save the file and run it, the stylesheet isn't being loaded for some strange reason :(

Could anyone help me please?

PS: Just in case, my index.php file looks like this:

<!doctype html>
<html <?php language_attributes();?> >
<head>
    <meta charset="utf-8" />
    <title><?php echo bloginfo('title');?></title>
    </?php wp_head();?>
</head>

<body>
    <?php get_header();?>

    <h1>My Site</h1>
    <?php echo get_template_directory_uri() . '/css/base.css';?>

    <?php get_footer();?>
    <?php wp_footer();?>
</body>
</html>
1

1 Answers

0
votes

get_template_directory_uri() returns the base theme directory so in essence it returns http://yoursite.com/wp-content/themes/mySite/. You need to add css/ to the path so it becomes:

wp_enqueue_style('test', get_template_directory_uri() . '/css/base.css');