Skip Navigation

[Resolved] Need help with getting count of events by state

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

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 3 replies, has 2 voices.

Last updated by Luo Yang 4 years, 9 months ago.

Assisted by: Luo Yang.

Author
Posts
#1511219

If I were writing a sql query for this it would be:

SELECT state, count(*)
FROM events
WHERE state is not null
GROUP BY state

and I'd want this result:

STATE COUNT
Maryland 5
Virginia 11
Utah 3

I tried to use [wpv-items-count] but I get duplicate states and counts so it's not grouping by state.

#1512319

Hello,

I assume we are talking about this case:
1) A custom post type "Event"
2) A custom taxonomy "State", rigistered to above post type.

If it is, you can try to setup a nested view.

For example:
1) Parent taxonomy view:
- query terms of taxonomy "State",
- in view's loop, display below child post view

2) Child post view:
- Query "Event" posts
- Filter by:
Select posts with taxonomy:
State set by the parent Taxonomy View
- outsider view's loop, display shortcode [wpv-found-count]

More help:
https://toolset.com/documentation/user-guides/views/using-a-child-view-in-a-taxonomy-view-layout/
hidden link

#1519809

Please don’t close this yet. The setting error has not been resolved so I haven’t had a chance to test Luo’s code. Jim

#1519891

I have marked this thread as waiting for feedback status, so you can update herer when you need more assistance.