Skip Navigation

[Résolu] Filtering view output by date range and relationship count

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.

Marqué : ,

This topic contains 1 réponse, has 2 voix.

Last updated by Minesh Il y a 10 mois et 3 semaines.

Assigned support staff: Minesh.

Auteur
Publications
#1870521

I want to create a view that shows how many "Setlists" a "Chart" is used in over a period of time.

"Setlists" and "Charts" are both CPTs. They are in a relationship through an intermediary post type "Charts Setlists." The Setlist CPT uses a required custom date field—this is what I want to use for the date range filtering.

The very basic idea is to display each result in a row where the Chart name is on the left and the quantity (#) of Setlists that Chart has been connected to is on the right. Example:

Song Name One 3 (number of Setlists this Chart is attached)
Song Name Two 7
Song Name Three 4

I've been able to find ways to display this info using one view for Setlists with [wpv-items-count] inserted into another view for Songs, but then the date filter doesn't work because the date filter is connected to Setlists.

Anyway, I hope I've explained this well, and am hoping there is a solution. If you need more from me please let me know.

#1871501

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

The thing is that, you can filter the view using custom fields that is associated with post type you set to query your view. Having said that, if you set your view to query post type Songs, you can add frontend filters/custom search filters for the custom fields that should belongs to post type Songs.

There is no way to filter the view using custom field that is part of another post type as it will give you unexpected results and its not recomonded.

The workaround would be to copy the date field to your song post type by adding a new date custom field to your song post type and then add the date filter.