[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.
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.
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).
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.
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.
"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?
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.
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).