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

Jena McWhirter
Jena McWhirter
2,702 Points

Errors with "How to Link to JS from functions.php File8:18 with Zac Gordon"

At the end of video "How to Link to JS from functions.php File8:18 with Zac Gordon" he is about to add code on line 4 and then the video ends with no info.

After the header and footer steps I am getting an error saying "Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'wp_theme_js' not found or invalid function name in C:\wamp64\www\folio1\wp-includes\class-wp-hook.php on line 298".

So Im guessing something is wrong when calling in the javascript because my CSS looks fine and I've double checked my coding. Can anyone help with this?

2 Answers

Chris Howell
.a{fill-rule:evenodd;}techdegree seal-36
Chris Howell
Python Web Development Techdegree Graduate 49,610 Points

Hi Jena McWhirter

So at the end of the video, Im not sure he was going to add another line of code, I believe he was just adding a Line Break between lines 3 and 4 so it was easier to read. When he said "we will add that here as well" he was using his mouse movement back and forth to show the line he just wrote and then spaced it so it looked nice and not cluttered together.

As far as your error looks, you could have a misspelling of your wp_theme_js inside your add_action function.

If you copied letter for letter, his is name wpt_theme_js. (Dont forget the 't'). If that is the case the add_action line underneath your wpt_themes_js would be.

add_action( 'wp_enqueue_scripts', 'wpt_theme_js' );

Though you could of totally named that function anything you wanted, so they have to match. Not even 1 letter off.

Let me know if that helps, if you still have problems, try using the Markdown Cheatsheet when you reply to post a code snippet of your functions.php file.

Jena McWhirter
Jena McWhirter
2,702 Points

Thank you! All I needed to do was add the 't', very much appreciated!