How to Prevent jquery.mousewheel.js from Loading o

2019-09-01 18:51发布

问题:

Ok, so I've managed to get horizontal scroll via mousewheel working for my my Wordpress site using the Expositio theme (http://wpshower.com/themes/expositio/)

This uses Brandon Aaron's Jquery-Mousewheel which can be found here : https://github.com/brandonaaron/jquery-mousewheel/zipball/master/ (for those of you who had difficulty finding a working link like I did!)

After this code in my Header.php :

        <?php
        wp_enqueue_script( 'jquery' );

        if ( is_singular() && get_option( 'thread_comments' ) ) wp_enqueue_script( 'comment-reply' );
        wp_head();
    ?>

I've inserted this :

<script type="text/javascript" src="<?php bloginfo("template_url"); ?>/includes/jquery.mousewheel.js"></script>

<script type="text/javascript">
jQuery(function($) {
    $('html, body').mousewheel(function(event, delta) {
        this.scrollLeft -= (delta * 90);
        event.preventDefault();
    })
});
</script>

Which works perfectly & looks great with this theme (I hope this information above is useful to a another newbie like me - the '90' denotes speed - I found the default 30 to be too slow a scroll for the content on my website)

However, I want the horizontal scrolling to not load for specific pages such as the 'About' etc. In fact, it could maybe work if this plugin was prevented from loading on all pages (since these don't have the horizontal layout that the rest of Expositio theme has)

Does anyone have any idea what code might work to make this possible? I want posts to load horizontal mousewheel scrolling, but not pages (or at least be able to exclude specific pages). I'd really appreciate any help - I'm fed up of floundering around in the dark! :)

回答1:

<?php
if(!is_page()) { ?>

<script type="text/javascript" src="<?php bloginfo("template_url"); ?>/includes/jquery.mousewheel.js"></script>

<?php } ?>