Skip Navigation

[Resolved] Group view’s results by custom field

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

Problem:
The user would like to display results of a view, grouped by a custom field.

Solution:
This use case is not supported out of the box by Toolset. Because the view loops over a list of Posts, and you are trying to loop over a list(Inspirations) of lists(Posts). But, this can be achieved with some custom PHP code.

Please check our article about a similar use case, grouping posts by year/month https://toolset.com/2013/10/how-to-group-views-results-by-year-and-month/

The trick is to order the view by the grouping element, in your case the inspiration custom field.

Relevant Documentation:
https://toolset.com/2013/10/how-to-group-views-results-by-year-and-month/

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

This topic contains 2 replies, has 2 voices.

Last updated by roulartaM 3 years, 5 months ago.

Assisted by: Jamal.

Author
Posts
#1851143

Hi Jamal,

Thanks a lot (!) for all the effort you've put in solving my problem. Believe it or not, but the problem was due to a setting in my hosting provider (Combell). What I had to do was disabling the 'SQL injection detection'-setting in the 'Security' tab. This afternoon, I"ve done some additional tests to be very sure and I must confirm that Toolset and the filter works correctly again! I'm very glad it's solved!

In the meantime, can I ask an additional question that has to do with the same page please? The output of the 'partners' on the 'addresses' page should be grouped by a custom field called 'Inspiration'. So this is what I should achieve:

Title inspiration 1
Shop 1 | Shop 2 | Shop 3 | Shop 4

Title inspiration 2
Shop 5 | Shop 6 | Shop 7

Title inspiration 3
Shop 8 | Shop 9 | Shop 10 | Shop 11 | Shop 12 | Shop 13

Title inspiration 4
Shop 14 | Shop 15 | Shop 16

At first glance, I thought it would be very easy by creating an extra view that loops through the "inspirations". But I see that there's no way to select that inspiration in the Content Selection. Perhaps there's another solution to achieve this? Or isn't it possible to loop through custom field values?

Kind regards,
Sam Clauw

#1851151

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

This use case is not supported out of the box by Toolset. Because the view loops over a list of Posts, and you are trying to loop over a list(Inspirations) of lists(Posts). But, this can be achieved with some custom PHP code.

Please check our article about a similar use case, grouping posts by year/month https://toolset.com/2013/10/how-to-group-views-results-by-year-and-month/

The trick is to order the view by the grouping element, in your case the inspiration custom field.

I hope this helps. Let me know if you have any questions.

#1854641

Hi Jamal,

It helped, thank you very much for your support!

Kind regards,
Sam from Roularta

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.