0

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.

Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
nathandrake
  • 427
  • 1
  • 4
  • 19
  • Use the console and let us know what errors you are receiving. What does "broken" mean? We will need more input before we can help. – Lee Taylor Jan 27 '14 at 03:24
  • I don't see any errors in console..I just see workings for fb code that I have put up. "broken" means that if I include jquery lib, only the js file I run on homepage works and no other js file for any other page works.. – nathandrake Jan 27 '14 at 03:27
  • Are you including jQuery twice(Wordpress includes it's own version)? try adding wp_deregister_script('jquery'); before you enqueue jQuery and change the handle 'custom_script' to 'jquery'. – joe42 Jan 27 '14 at 03:38
  • Can you provide link(s) to the page(s) in question? – Lee Taylor Jan 27 '14 at 03:46
  • I tried using the only difference being now all the pages are not working. I am sorry as the site is still in development.. – nathandrake Jan 27 '14 at 03:58
  • Please help me in resolving this one.. I am struck for over a month now and just cant figure this out.. – nathandrake Feb 19 '14 at 23:18
  • Please help me in resolving this one.. I am struck for over a month now and just cant figure this out.. – nathandrake Feb 20 '14 at 11:36

0 Answers0