Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

This plugin stopped working without modification. It was working last week. I've spent the last week working on something else, came back to it and not working. Any suggestions as to why?

<?php wp_enqueue_script("jquery"); ?>
<?php
if ( is_page('home') ) { 
   // If it's the home page, we want the slider, otherwise don't bother
   wp_register_script('easyslider',
       get_bloginfo('template_directory') . '/js/easySlider1.7.js');
   // enqueue the script
   wp_enqueue_script('easyslider');
}
?>
<?php
if ( is_page('our-services') ) { 
   // If it's the 'our services' page, we want the capty plug-in, otherwise don't bother
   wp_register_script('capty',
       get_bloginfo('template_directory') . '/js/jquery.capty.min.js');
   // enqueue the script
   wp_enqueue_script('capty');
}
?>
<?php wp_head();?>

<?php if ( is_front_page() ) { ?>
<script type="text/javascript">
    jQuery(document).ready(function($){ 
        jQuery("#slider").easySlider({
            auto: true, 
            continuous: true,
            numeric: true
        });
    }); 
</script>
<?php }; ?>
<?php if ( is_page('our-services') ) { ?>
<script type="text/javascript">
    jQuery(document).ready(function($){
        jQuery('#desktop,#advice,#infrastructure,#web').capty({
        animation: 'slide',
        speed:     400
        });
    });
</script>
<?php }; ?>

Ok, thanks for all the answers. It seems the problem was with another plug-in; I noticed that there was a new version of that plug-in available, installed that, and now everything is fine.

share|improve this question
Have you verified that there's no javascript errors in any of your other js files? That tends to cause javascript stuff following it to fail. – Rob Williams Mar 13 '11 at 9:10
I can get it to work fine if I deactivate another plug in. At the moment, Jquery loads, then my scripts, and then other jquery scripts like tools and ui, which are being called by the other plug in. I suspect that is the issue. I'm mystified though as to why it suddenly stopped working with no intervention. – Tony B Mar 14 '11 at 15:08
Would you have some webpage where we could see it in action ? – Kaaviar Mar 14 '11 at 16:22
No - it's not external at the moment. – Tony B Mar 15 '11 at 16:13

closed as too localized by Rarst Jan 1 '12 at 11:38

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

3 Answers

use if ( is_front_page() ) instead of if (is_page('home')) at the top.

share|improve this answer
tried that, still no joy. – Tony B Mar 12 '11 at 20:33
Right click on the page and click "View Source", then see if the easySlider.js file is loading correctly. – Pippin Mar 12 '11 at 21:33
yes, all the files seem to have loaded. – Tony B Mar 13 '11 at 7:54

Tony, you should use an action to enqueue your scripts. E.g. add something like this to your functions.php:

function register_script() {
   wp_register_script('capty',
       get_bloginfo('template_directory') . '/js/jquery.capty.min.js');
   // enqueue the script
   wp_enqueue_script('capty');
}
add_action( 'init','register_script');

If you want to load the scripts conditionally, you could take a look at http://scribu.net/wordpress/optimal-script-loading.html (article itself plus comments). Cheers, Peter

share|improve this answer
I've tried that, and they are now appearing before jquery and I get two extra errors. – Tony B Mar 13 '11 at 8:27
ok, I've used wp_enqueue_scripts instead of init. Now the scripts are loading right after jQuery; however I'm still getting the original error. Everything seems to have loaded if I view the source of the page. – Tony B Mar 13 '11 at 8:38

I had a similar problem in a friend's website. In my case it was because jQuery was being reloaded after the plugin, which reseted jQuery. Try to look in your source (especially in your theme's footer) if there's any plugin loading jQuery a second time.

share|improve this answer
As far as I can see (using Firebug) JQuery is only loading once. – Tony B Mar 13 '11 at 13:41
@TonyB check in Firebug console if jQuery loaded correctly. Try "alert(jQuery('#slider').html())". If it works, then something is preventing your plugin to register itself. – Rodrigo Sieiro Mar 13 '11 at 23:49
Yes, that works. I've had another look at it this morning and the problem seems to be related to another plug-in; mine works when this one is deactivated. Looking again at the Firebug net window, it's loading an extra 7 scripts, including jquery tools and JQuery ui scripts which are loading after the plug-in scripts. I'm hoping if I can get my scripts to load after those, it will work, but being a bit of a rookie with Wordpress, I'm not sure how to do this. – Tony B Mar 14 '11 at 10:06
Mark the other plugins as dependencies of yours. For example: wp_register_script('easyslider', get_bloginfo('template_directory') . '/js/easySlider1.7.js', array('jquery', 'jquery-ui');. I'm not sure what their aliases are, but you should find it in the other plugin's source (look for the lines that register them). – Rodrigo Sieiro Mar 14 '11 at 21:29
Thank you, that is very useful to know. – Tony B Mar 15 '11 at 16:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.