Hello,
I have a site with CPT called Events.
Each Event has custom fields with venue name, event date, event genre, etc.
I have managed to group entries based on venue name (hidden link) and display and filter some data. But I need to extract statistics based on custom fields - e.g. Total number of events is: 188
1) Venue 1 hosted 23 events during certain period which is X per cent of [wpv-found-count]
2) There were 16 events marked as "rock" genre, which is Y per cent of [wpv-found-count]
...
Could you kick me into a right direction how to achieve this, please?
You'll need custom code for this, and I expect you'd probably need to write several custom shortcodes.
Will the context always be a View listing all events? But you don't necessarily want to display these things for every iteration (i.e. every event), you would want some things shown once at the top? (E.g. There were 16 events marked as "rock" genre.)
You can pass the total number of events to your custom shortcode as shortcode content, e.g.
In the case of the rock genre statistic you would perform a query for events with the rock genre custom field (using get_posts), and could then perform your calculation with the results from that and the passed value of the View found results and return the required string.
For anything that you want to output for each iteration of the View loop, note that the current event post is available via the global $post object.
Hi Nigel,
thanks for your response. But you don't necessarily want to display these things for every iteration (i.e. every event), you would want some things shown once at the top? (E.g. There were 16 events marked as "rock" genre.)
Yes, that is exactly what I am trying to do as well
In the case of the rock genre statistic you would perform a query for events with the rock genre custom field (using get_posts)
OK, so I need to find a way in PHP, right? Any hint, please? I am not familiar with PHP (that's why I use Toolset 🙂 🙂 )
Sorry Tom, Toolset doesn't have the features you are looking for. I can't code new features for you. (I would suggest you submit a feature request, but in this case they are quite specific to your site and not so much a general purpose feature.)
If you are unfamiliar with PHP this is one time you'll need to involve a developer, I'm afraid.