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 trialGrant Smith
194 PointsParse error: syntax error, unexpected 'function' (T_FUNCTION). Header and Footer not showing?
Hi,
I have followed the video step by step. But the index.php is not rendering the header and footer files?
I turned on debug and this is the error I recieve.
Parse error: syntax error, unexpected 'function' (T_FUNCTION) in /Users/Grant/Documents/Transition Graphics/WEB-DEV-PROJECTS/themedev/wp-content/themes/tg-theme-dev/functions.php on line 3
So I copied and pasted the relevant code from the functions.php work file in case I had made a spelling mistake or something silly.
<? php
function tg_theme_styles() {
wp_enqueue_style( 'foundation_css', get_template_directory_uri() . '/css/foundation.css' );
//wp_enqueue_style( 'normalize_css', get_template_directory_uri() . '/css/normalize.css' );
wp_enqueue_style( 'googlefont_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 tg_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.min.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' );
?>
However I get the exact same error?
Simon Coates
28,694 Pointsdoes <?php vs <? php make a difference?
should the second parameter in addAction match the function name?
Grant Smith
194 PointsHi Simon,
Thanks very much, that sorted it.
1 Answer
Jessica Murillo
9,119 PointsI think that it is because you are calling the wrong function in:
add_action( 'wp_enqueue_scripts', 'wpt_theme_styles' );
it should be
add_action( 'wp_enqueue_scripts', 'tg_theme_styles' );
and this one
add_action( 'wp_enqueue_scripts', 'wpt_theme_js' );
should be
add_action( 'wp_enqueue_scripts', 'tg_theme_js' );
because you named them differently than the instructor.
Let me know if that helped!
Grant Smith
194 PointsGrant Smith
194 PointsWhilst doing some research as there is no point moving forward with course until this is resolved. It is suggested it may have something to do with my php version?
I am currently on PHP Version 5.6.10.
Didn't know if this would help with the diagnosing of the issue?