How to Prevent jquery.mousewheel.js from Loading on Pages in Wordpress

青春壹個敷衍的年華 提交于 2019-12-13 06:09:28

问题


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 } ?>


来源:https://stackoverflow.com/questions/19458532/how-to-prevent-jquery-mousewheel-js-from-loading-on-pages-in-wordpress

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!