Skip Navigation

[Closed] Group Views Results By Date & Custom Field

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.

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 1 year, 3 months ago.

Author
Posts
#2527691

I am following https://toolset.com/2013/10/how-to-group-views-results-by-year-and-month/ to group view results by date and a custom field.

The end goal is to achieve the first Post ID as shown below.

wpcf-review-date <-- Group By Date

-- wpcf-user-id <-- Group By User ID
---- Post ID <-- Show First Record
---- Post ID
---- Post ID
---- Post ID

-- wpcf-user-id <-- Group By User ID
---- Post ID <-- Show First Record
---- Post ID

I created function as follows:
//Group By Date
add_shortcode('group-date', 'group_date');

function group_date($atts, $content = '')
{
static $date = null;
static $uid = null;
$condition = $atts['condition'];
$value = $atts['value'];
switch ($condition) {
case 'date':
case 'uid':
if ($$condition != $value) {
$$condition = $value;
return $content;
}
break;
}
return '';
}

And for my view, it is as below.

[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<wpv-loop>
[group-date condition="date" value="[types field='review-date' style='text' format='d/m/Y']
[/types]"][types field='review-date' style='text' format='d/m/Y'][/types]
[/group-date]
[group-date condition="uid" value="[types field='closing-agent'][/types]"]
[types field='closing-agent'][/types]
[/group-date]
Reference: [wpv-post-title]
</wpv-loop>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-items-found]
[wpml-string context="wpv-views"]No items found[/wpml-string]
[/wpv-no-items-found]
[wpv-layout-end]

#2527873

Nigel
Supporter

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

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

Hi Vincent

Can you show a text example of what you expect the output to look like, as I'm having trouble visualizing what you are aiming for from your description.

Also, what does your current setup actually output?

The topic ‘[Closed] Group Views Results By Date & Custom Field’ is closed to new replies.