Skip Navigation

[Resolved] Grouping items in views page by custom field

This support ticket is created 6 years, 4 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 6 years, 4 months ago.

Assisted by: Nigel.

Author
Posts
#1104899

Hi.

So i have a website where i show custom post type "property" on a page. Only posts which have a custom field named "wpcf-ohome1" value lower than "next-monday" show in the view. Which is perfectly fine.

Now, what i want to achieve is, somehow group posts with same custom field value. So for instance all the posts with custom field "wpcf-ohome1" value equal to today's date show in one group, under one heading, let's say "Today or 11 September" and same goes for each date till this sunday.

I can provide more information if there appears to be any confusion. Thanks heaps in advance.

#1105357

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi there

Is the wpcf-ohome1 field a Types date field?

Because if so this is problematic.

Types date fields are stored as UNIX timestamps, e.g. the current timestamp as I'm writing is 1536653566.

And now it is 1536653673.

And now it is 1536653691.

That is not amenable to grouping in the way that you could group posts with fields such as "Monday", "Monday", "Tuesday", "Wednesday", "Wednesday" etc.

You can order the posts by the date field and then output the field in a custom format that only displays the day of the week, for example, so you would see them listed something like

Monday - post 1
Monday - post 2
Tuesday - post 3
Wednesday - post 4
Wednesday - post 4

Maybe that would be good enough.

But if you require

Monday
post 1
post 2
Tuesday
post 3
Wednesday
post 4
post 5

then you would effectively need to make a separate View for each.

Let me know your thoughts and I can expand if required.