I'm trying to create a thumb-navigation slider for the native WP galleries attached to a post. I did try using the flexislider module but couldn't get it to work with WP galleries. Since then, I have found the rather excellent BXSlider: hidden link and have got quite far in using it with the project post types on this site (in development):
hidden link
However, as you will see, the thumbnail navigation doesn't work. The thumbs require an index which I could get from the loop counter, if only I knew how. Following is the syntax required for the thumb pager:
<div id="bx-pager">
<a data-slide-index="0" href=""><img src="/images/thumbs/tree_root.jpg" /></a>
<a data-slide-index="1" href=""><img src="/images/thumbs/houses.jpg" /></a>
<a data-slide-index="2" href=""><img src="/images/thumbs/hill_fence.jpg" /></a>
</div>
I visited this URL:
https://toolset.com/documentation/user-guides/digging-into-view-outputs/#vmeta-wpv-loop-parameters
I hoped to find a way to output the current loop index (i.e [wpv-item index=?] , but I couldn't find it.
I tried using the [wpv-item] shortcode on its own where the numbers "0", "1", "2" appear in the code above, but that didn't work either.
This is what I tried:
<!-- wpv-loop-start -->
<div id="bx-pager">
<wpv-loop>
<a data-slide-index=[wpv-item] href=""><img src="[wpv-bloginfo show='url']/wp-content/uploads/[wpv-post-field name='_wp_attached_file']" /></a>
</wpv-loop>
</div>
<!-- wpv-loop-end -->
So what should I use to output the current loopcount?
Thanks
Tim
OK...
I would still like to know whether its possible to input the current loop count in a loop, but for now I have fixed my particular issue. In the end i just went with a long list of conditionals. Its OK in this environment, because I can reasonably expect the client to keep to a max of ten images per post gallery...
So it goes like this:
(for producing the thumbnails on pages like this one):
hidden link
NOTE: This is a dev site, so you'll find it at this url before long:
hidden link
<!-- wpv-loop-start -->
<div id="bx-pager">
<wpv-loop>
[wpv-item index=1]
<a data-slide-index="0" class="navthumb" href=""><img src="[wpv-bloginfo show='url']/wp-content/uploads/[wpv-post-field name='_wp_attached_file']" /></a>
[wpv-item index=2]
<a data-slide-index="1" class="navthumb" href=""><img src="[wpv-bloginfo show='url']/wp-content/uploads/[wpv-post-field name='_wp_attached_file']" /></a>
[wpv-item index=3]
<a data-slide-index="2" class="navthumb" href=""><img src="[wpv-bloginfo show='url']/wp-content/uploads/[wpv-post-field name='_wp_attached_file']" /></a>
[wpv-item index=4]
<a data-slide-index="3" class="navthumb" href=""><img src="[wpv-bloginfo show='url']/wp-content/uploads/[wpv-post-field name='_wp_attached_file']" /></a>
[wpv-item index=5]
<a data-slide-index="4" class="navthumb" href=""><img src="[wpv-bloginfo show='url']/wp-content/uploads/[wpv-post-field name='_wp_attached_file']" /></a>
[wpv-item index=6]
<a data-slide-index="5" class="navthumb" href=""><img src="[wpv-bloginfo show='url']/wp-content/uploads/[wpv-post-field name='_wp_attached_file']" /></a>
[wpv-item index=7]
<a data-slide-index="6" class="navthumb" href=""><img src="[wpv-bloginfo show='url']/wp-content/uploads/[wpv-post-field name='_wp_attached_file']" /></a>
[wpv-item index=8]
<a data-slide-index="7" class="navthumb" href=""><img src="[wpv-bloginfo show='url']/wp-content/uploads/[wpv-post-field name='_wp_attached_file']" /></a>
[wpv-item index=9]
<a data-slide-index="8" class="navthumb" href=""><img src="[wpv-bloginfo show='url']/wp-content/uploads/[wpv-post-field name='_wp_attached_file']" /></a>
[wpv-item index=10]
<a data-slide-index="9" class="navthumb" href=""><img src="[wpv-bloginfo show='url']/wp-content/uploads/[wpv-post-field name='_wp_attached_file']" /></a>
[wpv-item index=other]
</wpv-loop>
</div>
<!-- wpv-loop-end -->