灯箱2无法与Wordpress一起使用 [英] Lightbox 2 not functioning with Wordpress

查看:120
本文介绍了灯箱2无法与Wordpress一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它可以与网站的静态版本一起正常工作,但是将其转移到WP版本后,单击图像仅会导航到新页面,而不是像静态版本一样将LB放在顶部.模板:

It works fine with the static version of the website, but after transferring it to the WP version, clicking the image simply navigates to a new page, instead of bringing the LB up over the top, like on the static version. The template:

<?php
/*
Template Name: Work Child Page
*/
?>
<?php include 'header.php'; ?>

<?php while ( have_posts() ) : the_post(); ?>

<div class="col-md-10">
    <div class="row bottom-margin">
        <div class="col-md-12">
            <h3><?php the_field('title'); ?></h3>
        </div>
    </div>
    <div class="row">
        <?php           
            if(have_rows('images')):
                while(have_rows('images')): the_row();?>
                    <?php if(get_sub_field("image")): ?>

                        <div class="col-md-2 bottom-margin" data-title="" data-lightbox="Vacation">
                            <a href="<?php the_sub_field('image'); ?>">
                                <img class="img-responsive" src="<?php the_sub_field('image'); ?>" alt="">
                            </a>
                        </div>

                    <?php endif; // end of if field_name logic ?>   
                <?php endwhile;?>
            <?php endif;?>  

    </div>
</div>

<?php endwhile; // end of the loop. ?>

<?php include 'footer.php'; ?>

控制台不会显示任何JS错误.它使用ACF转发器,该转发器称为"images",其中一个子字段"image"为image类型,并返回图片URL值?

The console doesn't bring up any JS errors. It uses ACF repeater, the repeater is called "images" with one subfield "image" which is of type image and returns an image URL value?

推荐答案

查找此代码

<a href="<?php the_sub_field('image'); ?>">
    <img class="img-responsive" src="<?php the_sub_field('image'); ?>" alt="">

并替换为此

<a href="<?php the_sub_field('image'); ?>" rel="lightbox">
    <img class="img-responsive" src="<?php the_sub_field('image'); ?>" alt="">

这篇关于灯箱2无法与Wordpress一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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