通过按钮/链接触发Wordpress图像库

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了通过按钮/链接触发Wordpress图像库相关的知识,希望对你有一定的参考价值。

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

画廊短代码:[gallery ids="55,67"]

提前致谢。

答案

你可以这样试试。

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

以上是关于通过按钮/链接触发Wordpress图像库的主要内容,如果未能解决你的问题,请参考以下文章

markdown WordPress主题参考,如何,片段,存储库说明

仅显示前 9 个图像 ACF 库和链接中的触发器库

PHP 使用帖子附件的Wordpress图像库短代码

Android:片段内的按钮操作

HTML代码片段

HTML代码片段