Skip Navigation

[Resolved] Loop with different numbers of items

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

Problem:
how to display posts using views group by custom titles with different numbers of items

Solution:
You should create view's par section and use view's "Limit and Offset" section to limit the number of posts and skip the number of posts.

You can find proposed solution, in this case, with the following reply
https://toolset.com/forums/topic/loop-with-different-numbers-of-items/#post-852320

Relevant Documentation:

This support ticket is created 6 years, 6 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.

Our next available supporter will start replying to tickets in about 1.29 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 6 replies, has 2 voices.

Last updated by hugoC-3 6 years, 6 months ago.

Assisted by: Minesh.

Author
Posts
#832969

I am trying to set up a category menu with Views as follows:
Section 1 title
- item 1
- item 2
- item 3
- item 4
Section 2 title
- item 5
- item 6
Section 3 title
- etc.

I studied the documentation on setting up loops (wrap, pad, index).
My problem here is that every section has a different number of items. How can I handle this situation?

#838199

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - could you please let me know how the "Section" is configured with your setup. Is it setup as taxonomy? so "Section 1 title" will be taxonomy term.

Do you want to group your posts by taxonomy term?

#841379

"Section" is not a taxonomy, as I see it ; it's just a title.

Like
[wpv-item index=1]
<h4>Section tiltle 1</h4>
[wpv-post-link]
etc.
[wpv-item index=5]
<h4>Section tiltle 2</h4>
[wpv-post-link]
etc.

I guess I could give each indiviual item an index, but there may be an esasier way.

It could be that a taxonomy if that is easier.

#841449

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

So - you want to just give custom title and list post? Is there any condition based on which you want to give section title?

When you use index attribute with [wpv-item] shortcode - the section will be displayed for currently displayed index only.

#847839

There is no specific condition so far.
I just want to group a number of posts, say Section 1 = the first 4 posts, Section 2 = the next 5 posts, Section 3 = the following 3 posts etc. I would like to group the posts based on their content.

#852320

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

If there is no condition - then better you should create view's par section and use view's "Limit and Offset" section to limit the number of posts and skip the number of posts.

For example:

<h4>Section tiltle 1</h4>
[wpv-view name="view-1"]   // set limit to 5


<h4>Section tiltle 2</h4>
[wpv-view name="view-2"]   // set limit to 5 and skip 5

<h4>Section tiltle 3</h4>
[wpv-view name="view-3"]   // set limit to 5 and skip 10
#857066

Good suggestion, thanks!