如何防止jquery.mousewheel.js在Wordpress中的页面上加载 [英] How to Prevent jquery.mousewheel.js from Loading on Pages in Wordpress

查看:110
本文介绍了如何防止jquery.mousewheel.js在Wordpress中的页面上加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,所以我设法使用Expositio主题通过鼠标滚轮在我的Wordpress网站上进行水平滚动( http://wpshower.com/themes/expositio/)

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/)

这使用了Brandon Aaron的Jquery-Mousewheel,可以在这里找到: https://github.com/brandonaaron/jquery-mousewheel/zipball/master/(对于那些像我一样难以找到工作链接的人!)

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!)

在我的Header.php中的这段代码之后:

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();
    ?>

我插入了这个:

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

哪个可以完美运行?这个主题看起来很棒(我希望上面的信息对另一个像我这样的新手很有用-"90"表示速度-我发现默认值30太慢,无法滚动显示我网站上的内容)

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)

但是,我希望水平滚动到 not 而不加载特定页面(例如关于"等).实际上,如果阻止了此插件在 all上加载,则可能可以工作页面(因为这些页面没有Expositio主题其余部分的水平布局)

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)

有人知道什么代码可以使之成为可能吗?我希望 posts 加载水平的鼠标滚轮滚动,但不加载 pages (或至少能够排除特定页面).我真的很感谢您的帮助-我对在黑暗中挣扎的困境感到厌烦! :)

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! :)

推荐答案

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

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

<?php } ?>

这篇关于如何防止jquery.mousewheel.js在Wordpress中的页面上加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆