【问题标题】:Trigger Wordpress Image Gallery Via Button/Link通过按钮/链接触发 Wordpress 图片库
【发布时间】:2018-06-12 13:52:14
【问题描述】:

我想在带有按钮或链接的灯箱中打开默认的 Wordpress 画廊,并在页面上隐藏画廊缩略图。我怎样才能做到这一点?

图库短代码:[gallery ids="55,67"]

提前致谢。

【问题讨论】:

    标签: wordpress button hyperlink gallery lightbox


    【解决方案1】:

    你可以这样试试。

    <style>
        .hiddengallery{
            display:none;
        }
    </style>
    
    
    
    <button class="showgallery" >click here</button>
    
    <div class="hiddengallery"> 
        // add lightbox code here
        <?php echo do_shortcode('[gallery ids="55,67"]');?>
    </div>
    
    
    <script>
        jQuery(document).on("click",".showgallery", function (){
            jQuery(".hiddengallery").show();
        });
    </script>
    

    【讨论】:

    • 谢谢,但这只是隐藏/取消隐藏画廊的缩略图。您将需要再次单击其中一个缩略图以在默认灯箱内显示图像。我尝试的是用一个按钮模拟对第一个画廊缩略图的点击。
    • 我通过模拟点击隐藏图库的第一个缩略图解决了这个问题:jQuery(".gallery-item:first-of-type &gt; .gallery-icon &gt; a").trigger("click");
    猜你喜欢
    • 2023-04-04
    • 1970-01-01
    • 2017-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-12
    • 2015-03-09
    相关资源
    最近更新 更多