2014-10-08 96 views
0

我在wordpress中制作了一个自定义模板,除featherlight.js外,其他所有工作都很好,除非在网站的非WordPress版本中工作,但在Wordpress模板中不起作用。所有文件都从服务器成功加载。现在,图像将在新窗口中打开,而不是在Lightbox中打开。featherlight.js在Wordpress自定义模板

featherlight.min.css - 在style.css文件中加载@import url('css/featherlight.min.css');

featherlight.min.js - 加载</body>标记之前 - <script src="<?php bloginfo('template_url') ?>/js/featherlight.min.js" type="text/javascript" charset="utf-8"></script>

形象的例子:

<a href="<?php bloginfo('template_url'); ?> /img/ss/scrsht2-big.jpg" data-featherlight="image"><img src="<?php bloginfo('template_url'); ?> /img/scrsht2.jpg" /></a> 
+0

你是否已经通过以下方式将脚本“排队”为“正确的方式”:http://codex.wordpress.org/Function_Reference/wp_enqueue_script?某处可能存在javascript冲突。 – rnevius 2014-10-08 13:11:47

+0

你使用的是什么版本的jQuery? – Macsupport 2014-10-08 13:14:10

+0

只是改变它与jQuery 1.11.1一起加载入队。现在控制台说:“未捕获的ReferenceError:未定义jQuery”,尽管jQuery文件已正确加载。 – yuvalsab 2014-10-08 14:51:52

回答

1

正如我不能发表评论,下面是我想象的不同点可能会解释你的问题。

  1. 确保您已排队脚本通过以下方式(而不是被遗忘的jQuery):

    <?php 
    
    function enqueue_my_scripts() { 
        wp_enqueue_script('jquery'); //include jQuery version bundled with Wordpress in your page 
        wp_enqueue_style('featherlight', get_template_directory_uri() . '/css/featherlight.min.css'); 
        wp_enqueue_script('featherlight', get_template_directory_uri() . '/js/featherlight.min.js', array('jquery')); 
    
    } 
    add_action('wp_enqueue_scripts', 'enqueue_my_scripts'); 
    
    ?> 
    
  2. 检查是否jQuery version bundled with your Wordpress version适合你的插件。

  3. 绑定的jQuery在no-conflict mode中运行。确保在这种模式下可以读取初始化插件(如果有的话)的脚本 - 基本上使用jQuery而不是$details here)。

  4. 如果您正在使用儿童主题,请注意,bloginfo('template_url'),作为get_template_directory_uri();,返回指向父主题的链接。在这种情况下,请改用get_stylesheet_directory_uri()