I am using the following code in wordpress:
<?php
function my_scripts_method() {
if (is_page_template('front-page.php')) {
// register your script location and dependencies
wp_register_script('custom_script',
get_template_directory_uri() . '/includes/jquery-1.10.2.min.js', array('jquery')
);
// enqueue the script
wp_enqueue_script("custom_script");
// add_action('wp_enqueue_scripts', 'my_scripts_method');
// register your script location and dependencies
wp_register_script('custom_script1',
get_template_directory_uri() . '/includes/masonry.pkgd.min.js',
array('jquery')
);
// enqueue the script
wp_enqueue_script('custom_script1');
// add_action('wp_enqueue_scripts', 'my_scripts_method');
// register your script location and dependencies
wp_register_script('custom_script2',
get_template_directory_uri() . '/includes/unslider.min.js',
array('jquery')
);
// enqueue the script
wp_enqueue_script('custom_script2');
// register your script location and dependencies
wp_register_script('custom_script3',
get_template_directory_uri() . '/includes/front-page.js',
array('jquery')
);
// enqueue the script
wp_enqueue_script('custom_script3');
}
if (is_page_template('our-story.php')) {
wp_register_script('custom_script4',
get_template_directory_uri() . '/includes/parallax.js',
array('jquery')
);
// enqueue the script
wp_enqueue_script('custom_script4');
}
wp_register_script('custom_script5',
get_template_directory_uri() . '/includes/jquery.fancybox.js',
array('jquery')
);
// enqueue the script
wp_enqueue_script('custom_script5');
}
add_action('wp_enqueue_scripts', 'my_scripts_method');
?>
The problem I am facing is with the first /jquery-1.10.2.min.js lib. When I include this, it works well only on the front-page.php (homepage) while no other jquery functions work as expected on any of the other pages. Now when I remove this lib, the homepage get broken. Any suggestions how do I fix this one? I tried using noconflict function but still I get the same results. Also I don't using $ (using jQuery) in my js files.
Moreover the condition if (is_page_template('front-page.php')) isn't working on homepage.