I have a custom view which duplicates the last post when there's an odd number of pages:
hidden link
As I look at the view I can tell it's because of the two column setup:
[wpv-layout-start]
<wpv-loop wrap="2" pad="true">
[wpv-item index=1]
<div class="row-fluid"><!– open row –>
<div class="first-column one-half">
<h2>[wpv-post-link]</h2>
<p>[wpv-post-excerpt]</p>
</div>
[wpv-item index=2]
<div class="second-column one-half">
<h2>[wpv-post-link]</h2>
<p>[wpv-post-excerpt]</p>
</div>
</div><!– close row –>
[wpv-item index=pad]
<div class="row-fluid"><!– open row –>
<div class="first-column one-half">
<h2>[wpv-post-link]</h2>
<p>[wpv-post-excerpt]</p>
</div>
[wpv-item index=pad-last]
<div class="second-column one-half">
<h2>[wpv-post-link]</h2>
<p>[wpv-post-excerpt]</p>
</div>
</div><!– close row –>
</wpv-loop>
[wpv-no-posts-found][/wpv-no-posts-found]
[wpv-layout-end]
I wonder how should I restructure the view so the second column is conditional if Toolset runs out of posts to display?
Cheers
Hello,
Those two items in view's loop should be just placeholder and empty:
- index=pad
- index=pad-last
So you can modify your codes from:
...
[wpv-item index=pad]
<div class="row-fluid"><!– open row –>
<div class="first-column one-half">
<h2>[wpv-post-link]</h2>
<p>[wpv-post-excerpt]</p>
</div>
[wpv-item index=pad-last]
<div class="second-column one-half">
<h2>[wpv-post-link]</h2>
<p>[wpv-post-excerpt]</p>
</div>
...
To:
...
[wpv-item index=pad]
<div class="row-fluid"><!– open row –>
<div class="first-column one-half">
</div>
[wpv-item index=pad-last]
<div class="second-column one-half">
</div>
...
See our document:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-item
index=pad will be executed if there are no records left to output, but the number of records is not a multiple of the loop wrap value.
index=pad-last will be executed for the last item in the loop if are no records left to output, but the number of records is not a multiple of the loop wrap value.