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 trialKatherine Elsken
2,330 PointsProblem loading scripts in Genesis
I've been working on a project using Genesis and this is my first time using it. I'm having problems loading any kind of custom java scripts or jquery into my child theme.When I use the wp_enqueue_scripts function, my custom stylesheets load just fine, but not any other kind of scripts. I'm about ready to pull my hair out because this is the last major issue I need to fix in my theme
4 Answers
Zac Gordon
Treehouse Guest TeacherSee if this helps (from the Bootstrap course):
function theme_styles() {
wp_enqueue_style( 'main_css', get_template_directory_uri() . '/style.css' );
}
add_action( 'wp_enqueue_scripts', 'theme_styles' );
function theme_js() {
wp_enqueue_script( 'bootstrap_js', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'), '', true );
}
add_action( 'wp_enqueue_scripts', 'theme_js' );
Spencer Putnam
2,813 PointsHi Katherine. I've run into the exact same problem customizing themes on the Genesis framework. I've taken a lot of great suggestions from Genesis devs and meticulously combed through by code but still, no luck loading scripts in certain cases.
Did Zac's code help solve your problem? Or did you find any other resources online that answer some of the Genesis-related questions? Thanks!
Jonathan Seligsohn
23,116 PointsKatherine Elsken, are your JS files using jquery? If so, are you aware of jQuery, no-conflict-mode? Looks something like this:
jQuery(document).ready(function($) {
// Code here will be executed on document ready. Use $ as normal.
});
Otherwise, you can't use the '$' as WP thinks it refers to something else. See here for more info: http://matthewruddy.com/using-jquery-with-wordpress/
Saqib Ali
3,686 PointsHas the situation improved since this discussion began two years ago? I'm in a similar situation when using Genesis themes.
Katherine Elsken
2,330 PointsKatherine Elsken
2,330 PointsThis is what my code looks like for my javascript . sure enough it loads on the page in the source, but it still doesn't work.