Skip Navigation

[Resolved] Sorting by ‘odd’ or ‘even’

This thread is resolved. Here is a description of the problem and solution.

Problem:

Display different result in view's loop on odd/even condition.

Solution:

If you are using classic editor to create/edit the post view, you can setup the codes within view's loop like this:

https://toolset.com/forums/topic/sorting-by-odd-or-even/#post-2054945

Relevant Documentation:

https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-loop

https://toolset.com/documentation/legacy-features/views-plugin/digging-into-view-outputs/

This support ticket is created 3 years, 8 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 2 replies, has 2 voices.

Last updated by larsS 3 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#2054477

I found this argument in your support docs:
[wpv-conditional if="( '[wpv-items-count]' eq 'odd' )"]
<div class="odd-man-out">
<img src="[wpv-bloginfo show='stylesheet_directory']/images/logo-inverse.svg" alt="[wpv-bloginfo]" />
</div>
[/wpv-conditional]

Why am I unable to modify that to sort by 'post-id', like this?

[wpv-conditional if="( '[wpv-post-id]' eq 'odd' )"][wpv-post-id][/wpv-conditional]

#2054945

Hello,

Where did you find that support document?
The shortcode [wpv-items-count] can only output the number values of posts, users or taxonomies that will be displayed on the page, it can not output "odd" value, see our document:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-items-count

If you are using classic editor to create/edit the post view, you can setup the codes within view's loop like this:

...
    <!-- wpv-loop-start -->
        <wpv-loop wrap="2" pad="true">
            [wpv-item index=1]
This is odd item
            [wpv-item index=other]
This is even item
        </wpv-loop>
    <!-- wpv-loop-end -->
...

More help:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-loop
https://toolset.com/documentation/legacy-features/views-plugin/digging-into-view-outputs/

#2055541

My issue is resolved now. Thank you!