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 WordPress Theme Development Working with CSS and JS in WordPress Themes How to Link to JS from functions.php File

Alexa Brown
Alexa Brown
2,582 Points

Parse error: syntax error, unexpected 'get_template_directory_uri'

Parse error: syntax error, unexpected 'get_template_directory_uri' (T_STRING)

For some reason I am getting this error whenever I go to activate my theme that I am working on for the lesson. I have tried everything and I made sure that the code matches up with the one Zac gives in the lesson but nothing is clearing up for me.

Chris Shaw
Chris Shaw
26,676 Points

Hi Alexa,

Could you please post the current code you have as without it we can't determine what the issue it, thanks.

https://teamtreehouse.com/forum/posting-code-to-the-forum

3 Answers

Chris Shaw
Chris Shaw
26,676 Points

Hi Alexa,

You're missing commas after your script names in your wpt_theme_js function, currently you have a space before get_template_directory_uri but no comma, simply place that in there and your code should start functioning normally.

wp_enqueue_script( 'modernizr_js', get_template_directory_uri () . '/js/modernizr.js', '', '', false );
wp_enqueue_script( 'foundation_js', get_template_directory_uri () . '/js/foundation.js', array('jquery'), '' true );
wp_enqueue_script( 'main_js', get_template_directory_uri () . '/js/app.js', array('jquery', 'foundation_js'), '' true );

Happy coding!

Alexa Brown
Alexa Brown
2,582 Points
functions.php
<?php

function wpt_theme_styles() {

    wp_enqueue_style( 'foundation_css', get_template_directory_uri() . '/css/foundations.css' );
    wp_enqueue_style( 'normalize_css', get_template_directory_uri() . '/css/normalize.css' );
    wp_enqueue_style( 'normalize_css', 'http://fonts.googleapis.com/css?family=Asap:400,700,400italic,700italic' );
    wp_enqueue_style( 'main_css', get_template_directory_uri() . '/style.css' );

}
add_action( 'wp_enqueue_scripts', 'wpt_theme_styles' );

function wpt_theme_js() {

    wp_enqueue_script( 'modernizr_js' get_template_directory_uri () . '/js/modernizr.js', '', '', false );
    wp_enqueue_script( 'foundation_js' get_template_directory_uri () . '/js/foundation.js', array('jquery'), '' true );
    wp_enqueue_script( 'main_js' get_template_directory_uri () . '/js/app.js', array('jquery', 'foundation_js'), '' true );

}
add_action( 'wp_enqueue_scripts', 'wpt_theme_js' );

?>
Alexa Brown
Alexa Brown
2,582 Points

Thank you so much. I had forgotten some commas in a few more places too, thanks again!