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]
Nigel
Supporter
Languages:
English (English )
Spanish (Español )
Timezone:
Europe/London (GMT+00: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?