Fancybox gallery loop issue

夙愿已清 提交于 2019-12-11 17:52:55

问题


I have a problem with this code for a fancybox gallery which its showing all images across the page, when should be visible just the first one and then others, when you click.

How do i stop from showing all images and show just the first one before click?

<code>

    {% for slide in wp.get_post_meta(post.ID, '_property_slides', TRUE) %}
        <div class="carousel property">
            <div class="preview">
                <a rel="galeria{{ post.ID }}" href="{{ slide.imgurl }}">
                     <img src="{{ slide.imgurl }}" alt="">
                 </a>
            </div>
            <!-- /.preview -->

            <div class="content">
                <ul>
                    {% for slide in wp.get_post_meta(post.ID, '_property_slides', TRUE) %}
                        {% if loop.first %}
                            <li class="active" >
                        {% else %}
                            <li>
                        {% endif %}
                        <img src="{{ slide.imgurl }}" alt="">
                        </li>
                    {% endfor %}
                </ul>

                <a id="carousel-prev" href="#">{{ wp.__('Previous', 'aviators') }}</a>
                <a id="carousel-next" href="#">{{ wp.__('Next', 'aviators') }}</a>
            </div>
            <!-- /.content -->
        </div><!-- /.carousel -->
    {% endfor %}

</code>

回答1:


You have to change the first line:

// delete this line {% for slide in wp.get_post_meta(post.ID, '_property_slides', TRUE) %}
{% if wp.get_post_meta(post.ID, '_property_slides', TRUE) %} //use this one

and the last one:

// delete this line {% endfor %}
{% end %}


来源:https://stackoverflow.com/questions/20058164/fancybox-gallery-loop-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!