Skip Navigation

[Resolved] order nested view by custom field of parent post type

This support ticket is created 2 years, 3 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.

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)

This topic contains 7 replies, has 2 voices.

Last updated by LandruF8417 2 years, 3 months ago.

Assisted by: Minesh.

Author
Posts
#2434533

continuing from this support (https://toolset.com/forums/topic/view-to-list-posts-grouped-by-parent-post/) with Minesh, I would like to know if It is possible to have ordering for a nested view to be ordered by a custom field of it's parent post type.

#2434889

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

I will require to check the structure and review what I can do here.

I will require to know what parent field you would like to order by?

As the access details will be automatically deleted when ticket is resolved, may I kindly ask you to share admin access details and problem URL.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) 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.

#2435133

Minesh
Supporter

Languages: English (English )

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

The parent view is taxonomy view and within that you added the post type view to list posts group by taxonomy. Its no possible to display or further group posts by parent custom field (city).

#2435149

Ok. What changes can I make to so that it can work? Can I aadd a "city" taxonomy to the child posts and then order the child view by that taxonomy? Otherwise, please let me know any other overall change suggestions to get it to work.

Thanks

#2435173

Minesh
Supporter

Languages: English (English )

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

No, because we are using nested views, the results will be group by the parent and the parent view is taxonomy view.

There is no way to do that as lets say you have following current structure:
(where parent view is taxonomy view and you set to display terms order by ASC for taxonomy view and to group posts belongs to the term you are using child view that is assigned to the post):
- Taxonomy B and posts belongs to this taxonomy term 10
- Taxonomy A and posts belongs to this taxonomy term 5
- Taxonomy C and posts belongs to this taxonomy term 3

So it will start to loop through the parent taxonomy view order by ASC, so it will first display:
- A with posts 5
- B with posts 10
- C with posts 3

We do not have here control over the parent of child post type and we can not simple order the posts based on the child view post type's parent post type because looping and ordering will start based on the parent taxonomy view. You can say this is a limitation.

if you want to display the posts based on the city (belongs to parent post type locations) custom field order by ASC then you first have to create parent view belongs to locations set it to order by city field ASC and then child view should be for careers and the filter should be the post relationship filter.

#2435201

If I go with this idea:

"if you want to display the posts based on the city (belongs to parent post type locations) custom field order by ASC then you first have to create parent view belongs to locations set it to order by city field ASC and then child view should be for careers and the filter should be the post relationship filter."

will I still be able to have the grouping by state as it currently is?

#2435231

Minesh
Supporter

Languages: English (English )

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

when you set your view to order by city (parent post type) field then the child view will be set to fetch the posts (career) belongs to that city, so then you can not again group by state. Lets say you have multiple cities in the state Georgia then?

You should have post type structure like: State -> City -> post where State and city is a post types.

Then we can create a 3 level nested view. where first view will be to display State then with 1st level child view we will display cities belongs to the state and then 2nd level child view we can display posts belongs to the city.

But again, then it will be order by State name ASC then city name ASC and then career (post) ASC.

#2435235
Screen Shot 2022-08-10 at 10.38.46 AM.png

Thanks Minesh. To avoid adding two more CPTs, I decided to try adding a "city-of-career" field to the careers child post and sorted the child view by that field (see screenshot).

Thanks for all you help. I appreciate it!