Skip Navigation

[Resolved] Nested Event Calendar posts not sorting correctly

This support ticket is created 5 years, 5 months ago. 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.

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)

Tagged: 

This topic contains 8 replies, has 2 voices.

Last updated by charlesR-4 5 years, 5 months ago.

Assisted by: Minesh.

Author
Posts
#1343539
screening dates.jpg

I have a setup that uses one View nested within another. The first view fetches all of the Films posts within a certain taxonomy. Then, within that loop, for each Film Post a View is used to pull event posts from The Event Calendar plugin that are children of that Film Post and display those chronolgically according to the event start date field.

However, the event posts are not ordering correctly. I cannot tell how they are being ordered. It is neither chronological nor by menu order. It seems random.

I should note that in I use another View for a different page that displays these same children Event Calendar Posts on their own, not nested within another View. In that instance, they do display correctly, so I know it is not a problem with the posts themselves.

Link to a page where the issue can be seen: hidden link

#1343829

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

I see you are using Events calendar plugin. I would like to know here are you trying to sort by Events calendar date that is coming from events calendar? If yes, events calendar dates are stores as date string and we need to apply view's hook in order to sort the event calendar date in the correct order.

If able information is correct, can I have problem URL where you are displaying the events and access details?

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

#1344951

Minesh
Supporter

Languages: English (English )

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

Yes - its obvious as the child view that displays the event dates will display according to the parent post in loop:

 Filter by post relationship or repeatable fields group owner
Select posts that are a children of the current post in the loop.

So, it will query parent post view first and based on the sorting set on parent post it will fetch the child posts.

#1345189

I don't understand. Are you saying there is no way to sort the child View?

#1346053

Minesh
Supporter

Languages: English (English )

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

Let me try to explain;

Parent post 1
-- child post 1- date - 23-04-2017
-- child post 2- date - 25-05-2017
-- child post 3- date - 23-06-2017
Parent post 2
-- child post 4- date - 27-04-2017
-- child post 5- date - 2-04-2017
-- child post 6- date - 23-06-2017
Parent post 3
-- child post 7-date - 23-09-2017
-- child post 8- date - 25-11-2017
-- child post 9- date - 23-12-2017

Lets consider the above structure, as you added the child view to your parent view, with each parent view loop it will call the child view and the order will be followed of parent view. Do you only want to sort the child view posts?

#1346411

No, I need to sort the parent view by the title and the child view by the date field. However, if this is not possible, I can work around this if I know how the child view is being sorted. For example, if the child view is being sorted by title because the parent view is being sorted by title, then I can adjust the child post titles accordingly. But I do not know how the child posts are being sorted, if they are being sorted at all.

#1347065

Minesh
Supporter

Languages: English (English )

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

You can set the sorting option for your parent or child post view when you edit your parent/child view from the ordering section.

The thing is that parent view will query posts belongs to your parent post type and child view will query the posts belongs to your child post type. Child view sorting order will not have an effect on your parent view's sorting order. Having said that you can not sort the child view by parent view's sort order because both view will query different post types.

Now, when I activated the view's dubug :
=> https://toolset.com/documentation/programmer-reference/debugging-sites-built-with-toolset/#the-views-debug-tool

I found the following code is added to your theme's functions.php file and the child view order is affected by the order you set using the following code:

//  Sorts by temp column
function wpcf_sort_by_temp_column ($orderby) {
  $custom_orderby = "UPPER(title2) ASC";
  if ($custom_orderby) {
    $orderby = $custom_orderby;
  }
  return $orderby;
}

I do not know if the above code you added should be applied to your child view that displays the event dates.

#1347375

That code is for sorting the title alphabetically without preceding articles (A, And, The). I see by removing it that it is also overriding any sorting parameters on the child view. I will have to find another way of sorting the titles then.

#1347377

My issue is resolved now.