Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

WordPress WordPress Theme Development Working with CSS and JS in WordPress Themes How to Link to JS from functions.php File

Having problems linking JS, CSS and SCSS into functions.php PLEASE HELP!

Hi lovely people, I'm getting the following error message from my browser whilst trying to import js, css and scss files into functions.php.

Parse error: syntax error, unexpected ';', expecting '{' in C:\Users\me\Desktop\USBWebserver v8.6\root\wordpress\wp-content\themes\kadgltd\functions.php on line 3

I can't for the life in me figure out where the error is. Could anyone advise what i'm doing wrong?

Thank you very much in advance!!


function kadg_theme_styles(); { /CSS/ wp_enqueue_style('fa_css', get_template_directory_uri() . '/assets/css/font-awesome.min.css'); wp_enqueue_style('ie8_css', get_template_directory_uri() . '/assets/css/ie8.css'); wp_enqueue_style('ie9_css', get_template_directory_uri() . '/assets/css/ie9.css'); wp_enqueue_style('main_css', get_template_directory_uri() . '/style.css');

/SASS/ wp_enqueue_style('sass_main_scss', get_template_directory_uri() . '/assets/sass/main.scss'); wp_enqueue_style('sass_ie9_scss', get_template_directory_uri() . '/assets/sass/ie9.scss'); wp_enqueue_style('sass_ie8_scss', get_template_directory_uri() . '/assets/sass/ie8.scss'); wp_enqueue_style('libs_vars_scss', get_template_directory_uri() . '/assets/libs/_vars.scss'); wp_enqueue_style('libs_skel_scss', get_template_directory_uri() . '/assets/libs/_skel.scss'); wp_enqueue_style('libs_mixins_scss', get_template_directory_uri() . '/assets/libs/_mixins.scss'); wp_enqueue_style('libs_functions_scss', get_template_directory_uri() . '/assets/libs/_functions.scss');


add_action('wp_enqueue_scripts' , 'kadg_theme_styles');

function kadg_theme_js(); {

/JS/ wp_enqueue_scripts('util_js', get_template_directory_uri() . '/assets/js/util.js' , '' , '' , true); wp_enqueue_scripts('skel_min_js', get_template_directory_uri() . '/assets/js/skel.min.js' , '' , '' , true); wp_enqueue_scripts('main_js', get_template_directory_uri() . '/assets/js/main.js' , '' , '' , true); wp_enqueue_scripts('jquery_scrolly_min_js', get_template_directory_uri() . '/assets/js/jquery.scrolly.min.js' , '' , '' , true); wp_enqueue_scripts('jquery_scrollex_min_js', get_template_directory_uri() . '/assets/js/jquery.scrollex.min.js' , '' , '' , true); wp_enqueue_scripts('jquery_min_js', get_template_directory_uri() . '/assets/js/jquery.min.js' , '' , '' , true); wp_enqueue_scripts('jquery_dropotron_min_js', get_template_directory_uri() . '/assets/js/jquery.dropotron.min.js' , '' , '' , true);

    wp_enqueue_scripts('ie_respond_min_js', get_template_directory_uri() . '/assets/ie/respond.min.js' , '' , '' , true);
    wp_enqueue_scripts('ie_html5shiv_js', get_template_directory_uri() . '/assets/ie/html5shiv.js' , '' , '' , true);

} add_action('wp_enqueue_scripts','kadg_theme_js'); ?>

2 Answers

Joel Bardsley
Joel Bardsley
31,242 Points

There might be a few problems but the error is because you've included a semi-colon at the end of the function name before the opening curly brace. Remove this from both function kadg_theme_styles(); { and function kadg_theme_js(); { and that should fix that particular problem.

You also wouldn't want to enqueue your scss files in a WordPress theme, as these should be getting compiled into a single css file (ideally your theme's style.css file).

If you have any further issues/questions after attempting the above suggestions, let us know.

Any chance you could take a look at this Joel. Laptop is about 30 seconds away from being launched out of the window.


Hi Joel, Thanks for responding. I've only just embraced WordPress after years of hand coding. I appreciate any help I can get in getting my head around this. This is literally the first theme I've tried to build from scratch. It's like learning a whole new language despite it being based on a language I thought I had a pretty good understanding of. Beginning to feel like a newb coder again. :-(