The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 9 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.
I have a custom field that allows the user to enter a number value (in this case, the number of attendees at an event.) I'd like to display reporting on my site that shows the total number of attendees at all the events in each state.
Is it possible through Toolset to get a count of the values of several posts? Specifically, I'm trying to figure out how to show the total number of attendees in each state. So I would need to query all the posts by state, then count the values in the attendees fields of those records. Possible?
Although this is not offered by a Toolset short code so far, but you can achieve this very easily. Please add following code to your active theme's 'functions.php' file:
global $total;
add_shortcode('add-to-total', 'add_total_shortcode');
function add_total_shortcode($atts, $content = '') {
global $total;
$total += wpv_do_shortcode($content);
}
add_shortcode('show-total', 'show_total_shortcode');
function show_total_shortcode() {
global $total;
$totalNew = $total;
$total = 0;
return $totalNew;
}
This will add 2 new short codes to your system; [add-to-total] and [show-total]. The usage of these short codes will be as below (sample code):
Please notice, the use of [add-to-total]...[/add-to-total]. You will need to supply your "number of attendees" field as a content of this short code and will need to use it in View's loop (as shown above).
Please let me know if I can help you with anything related.