Passer la navigation

[Closed] Group Views Results By Date & Custom Field

This support ticket is created Il y a 3 years, 4 months. 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.

Ce sujet contient 1 reply, a 2 voix.

Dernière mise à jour par Nigel Il y a 3 years, 4 months.

Auteur
Publications
#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

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: 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.