Skip Navigation

[Resolved] Conditional display: if field equals field from previous post in loop

This support ticket is created 3 years, 2 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: Africa/Casablanca (GMT+01:00)

This topic contains 2 replies, has 2 voices.

Last updated by szymonF 3 years, 2 months ago.

Assisted by: Jamal.

Author
Posts
#2220095

I want to create a loop with section titles, to be displayed within a post relationship setup. Here is how I thought this could be done:

1. Parent post in a many-to-many relationship with child posts
2. View displays the related child posts within the parent post
3. Each child post has a Relationship custom text field 'section title'
4. The child post content template starts with a conditional which displays the 'section title' field only if it is different than the 'section title' of the previous post in the loop.

Is such a conditional possible?

#2220643

Hello and thank you for contacting the Toolset support.

If I understand well your request, you are looking to group the view's results by that custom field value. Only display it for the first post, then do not display it until it changes in the current post of the loop, right?
If yes, we have an article about it here, the trick is to order the view's results by that custom field https://toolset.com/2013/10/how-to-group-views-results-by-year-and-month/

If no, I hope that the custom code in the article inspires you to come up with a solution. Otherwise, please give me a concrete example to help me understand your use case, and I'll do my best to help you with it.

#2223515

Thanks for the link! I'll work it out 🙂