Skip Navigation

[Résolu] group view results by parent post and then by a custom date field

This support ticket is created Il y a 3 années et 2 mois. 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.

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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

Marqué : ,

This topic contains 5 réponses, has 2 voix.

Last updated by Rita Il y a 3 années et 2 mois.

Assisted by: Minesh.

Auteur
Publications
#1890773

Hi there

So I am not sure if this is possible but thought to ask just in case!
I would like to find out if it is possible to group a view's results by two groups, one nested in the other:
1. First by parent post titles/id
2. Then in those parent post groups group results by a custom date field

so the output could be... for example... a view of BOOKS grouped by their parent AUTHORS and then by the BOOK PUBLISH YEAR:

--> AUTHOR 1
------> BOOK PUBLISH YEAR 1
----------> book title
------> BOOK PUBLISH YEAR 2
----------> book title

--> AUTHOR 2
------> BOOK PUBLISH YEAR 1
----------> book title
------> BOOK PUBLISH YEAR 2
----------> book title
------> BOOK PUBLISH YEAR 3
----------> book title

I currently have a view working nicely with a shortcode (code in functions.php) to group the results by its custom date field and then a nested view that filters posts to find 1 particular post in the date group:
<wpv-loop>
[SHORTCODE-NAME condition="day" value="CUSTOM-DATE-FIELD"]
[wpv-view name="VIEW-NAME" date="CUSTOM-DATE-FIELD"]
[/SHORTCODE-NAME]
</wpv-loop>

Now I would like to wrap that in a parent post group....

Do you think its even possible?

Thanks in advance for your help.

Rita

#1891357

Minesh
Supporter

Languages: Anglais (English )

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

Hello. Thank you for contacting the Toolset support.

I'm not sure what is the relationship of your parent post here. Do you have a one to many relationship with your post type and you want to group your post by parent post, as you already group your child post by custom field. If this is correct:
. You will require another view that should be set to query your parent post type and you should display the parent post title within the view's loop editor section and add the post relationship filter to your child post type.

For example:
=> https://toolset.com/documentation/legacy-features/views-plugin/displaying-related-child-posts/#1-creating-a-view-that-lists-the-children-of-the-parent-post

Where, you will require to add your child view to your parent view's loop editor and to your child view add a post relationship filter and set it to use the option "The current post in loop".

That way I think you should be able to display your posts group by parent.

#1891487

Hi Minesh

Thanks for your quick response and happy new year!

Yes, I should have clarified a bit further in my initial enquiry:

1. Yes. The parent post is in a one to many relationship with the child post set up with Toolset Relationships.

2. I currently have a setup with a parent view and inside that loop the nested child post view to group the child posts by date and then inside each date group another nested view to find one particular child post.

The problem is the three views - parent view, child date view, child view - is loading too slowly and causing a 503 error.

FYI:
1. I have php performance set very high on the server
2. The page that loads the views has no header, footer or any other content
3. The view itself calls for text only (no images etc)
4. Output is currently about 500 posts

So, I am trying to find a way to remove the need for 3 nested views...

Do you think it is possible to group results by a parent post and a custom date field?

The only other option I can think of is to see if it is possible to add a second custom field sort filter on the main child post view nested in the parent view. Currently I must sort the view by the custom field date to create the date groups. If I could sort that view by a second custom field it might work. Is that possible?

Look forward to hearing your thoughts.

#1891491

Minesh
Supporter

Languages: Anglais (English )

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

I will require to review your current setup and what views are involved and how you setup those.

Can you please share problem URL and access details so I can see whats going wrong with your setup.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#1891577

Minesh
Supporter

Languages: Anglais (English )

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

The site is too slow and I hardly just logged in after 10 minutes and pages are just keep loading and loading.

However - the first thing I notice with the installation you shared is you are using outdated Toolset plugins, can you please update ALL Toolset plugins to it's latest official released version. We always recommend running your site with the latest stable release plugin version.

*** Please make a FULL BACKUP of your database and website.***
You can download the latest plugin release from your accounts page:
=> https://toolset.com/account/downloads/

Note: Please update WordPress version to 5.6.

Then I checked the structure of your data and I found that you have almost 250 events and 2200 tickets (Products) and this is too much content to display on a single page.

I tried to access the page: hidden link - and after 5-10 minutes it shows me the error "502 gateway timeout" - this is where you want to improve. But with the amount of the data you have this is expected.

The only way that we can improve here is we will require to add pagination and display 10 results per page:. I've added the pagination to your top level view:
=> hidden link

And I can see now it displays the results:
=> hidden link

#1891645

Thank you for your time and advice Minesh!
We will have to accept that there is no other way 🙂

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.