Skip Navigation

[Resolved] Duplicate posts on final page

This support ticket is created 2 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 1 reply, has 2 voices.

Last updated by Luo Yang 2 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#2569731

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

#2569933

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.