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 help!! JS not being registered on my theme

used this code in functions;

//Load the Theme JS function theme_js() {

wp_register_script('modernizr', get_template_directory_uri() . 'js/modernizr.custom.js', array('jquery'), '', true );
wp_enqueue_script ('toucheffects', get_template_directory_uri() . 'js/toucheffects.js', array('jquery'), '', true );

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

Doesn't work...

So in header also put;

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script src="<?php bloginfo( 'theme_url' ); ?>"></script>

that doesn't work either!! (also tried listing each js separately which makes it show in view source but when you click on it, it can't be found!! )

If I don't have anything in the header, then it won't show on view source!!!

Thanks

1 Answer

Christopher Hall
Christopher Hall
9,052 Points

You did place the Javascript files in the following directory, right?

/wp-content/themes/<your-theme-name>/js/

If the files are there, it could be a permissions issue. Your web server doesn't have permission to read the file(s)?