Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

My CSS is not loading

Hi all, spent all day on this, following the treehouse tutorial and its not working. I created this code in functions.php:

<?php

function fcd_theme_styles() {

wp_enqueue_style( 'style_css', get_template_directory_uri() . 'style') ;

wp_enqueue_style( 'style_css', get_template_directory_uri() . '/css/style') ;

wp_enqueue_style( 'boostrap_css', get_template_directory_uri() . '/css/bootstrap') ;

wp_enqueue_style( 'style_css', '//fonts.googleapis.com/css?family=Lato:300,300i,400,400i,700,900') ;

}

add_action('wp_enqueue_scripts', 'fcd_theme_styles');

function fcd_theme_js() {

wp_enqueue_script('', get_template_directory_uri() . '/js/core.min.js', '','', false );

wp_enqueue_script('', get_template_directory_uri() . '/js/html5shiv.min.js', '','', false );

wp_enqueue_script('', get_template_directory_uri() . '/js/pointer-events.min.js', '','', false );

wp_enqueue_script('', get_template_directory_uri() . '/js/script.js', '','', false );

add_action ( 'wp_enqueue_scripts', 'fcd_theme_js');

}

?>

I also added <?php wp_head(); ?> to header.php, and<?php wp_footer(); ?> to footer.php. I cannot for the life of me figure out why my CSS and Javascript files are not loading.

1 Answer

Alessandro Maculotti
Alessandro Maculotti
4,954 Points

I'm still new with wp but as far as I know you can't use the same name on the wp_enqueue_style function. Try to change 'style_css' and let me know.

More detail: https://developer.wordpress.org/reference/functions/wp_enqueue_style/