Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/430.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何获取Photoswip标题文本?_Javascript_Wordpress_Advanced Custom Fields_Photoswipe - Fatal编程技术网

Javascript 如何获取Photoswip标题文本?

Javascript 如何获取Photoswip标题文本?,javascript,wordpress,advanced-custom-fields,photoswipe,Javascript,Wordpress,Advanced Custom Fields,Photoswipe,我希望这不是一个太愚蠢的问题,但我已经在这个问题上纠缠了好几个小时,需要一些帮助/指导 我正在WP中使用ACF Gallery,现在我正试图将其转换为一个弹出式滑块。所以我决定使用Photosweep插件来实现这一点 我的滑块工作正常,只是我不知道如何输出每个图像的图像标题 <?php $popup_gallery = get_field('popup_gallery','option'); $popup_gallery_json = json_encode($popup_gallery,

我希望这不是一个太愚蠢的问题,但我已经在这个问题上纠缠了好几个小时,需要一些帮助/指导

我正在WP中使用ACF Gallery,现在我正试图将其转换为一个弹出式滑块。所以我决定使用Photosweep插件来实现这一点

我的滑块工作正常,只是我不知道如何输出每个图像的图像标题

<?php
$popup_gallery = get_field('popup_gallery','option');
$popup_gallery_json = json_encode($popup_gallery,JSON_FORCE_OBJECT);
?>

<div class="popup-gallery-data" data-json='<?php echo $popup_gallery_json;?>'
    data-json-length="<?php echo count($popup_gallery);?>" >
</div>
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="pswp__bg"></div>
    <div class="pswp__scroll-wrap">
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">
                <div class="pswp__counter"></div>
                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
                <button class="pswp__button pswp__button--share" title="Share"></button>
                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>
                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>
        </div>
    </div>
</div>


caption
应该是一个可用的键,以便您可以按如下方式更新代码:

 json.map((img) => {
        items.push({
            src: img.url,
            w: img.width,
            h: img.height,
            title: img.caption
        })
    })

谢谢你的回复。如何将标题输出到PSWP滑块中?看起来它使用了
title
键。。。更新了我的答案。哇,就是这么简单的改变。。。。。谢谢你的帮助
 json.map((img) => {
        items.push({
            src: img.url,
            w: img.width,
            h: img.height,
            title: img.caption
        })
    })