Skip Navigation

[Resolved] View to list posts grouped by parent Post

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.

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 26 replies, has 2 voices.

Last updated by LandruF8417 2 years, 3 months ago.

Assisted by: Minesh.

Author
Posts
#2429925
Careers-Section-Toolset-clean.png
Screen Shot 2022-08-02 at 6.56.46 PM.png

I need to create a view that list posts in groups by a custom field of their parent post type (not necessarily the same exact parent post). First loop will by "state" custom field of parent post type, second loop is alphabetical order of "city" custom field of parent post type. See attached for what I'm trying to achieve and the current setup of post relationships. I will also have a filter by radio buttons above the results that I am able to do, but I can't seem to get parent/child listings to work.

I tried following (https://toolset.com/documentation/legacy-features/views-plugin/displaying-related-child-posts/#1-creating-a-view-that-lists-the-children-of-the-parent-post) and (https://toolset.com/2015/07/how-to-group-posts-by-category/).
But it's was not working for me and I don't know if there is a better way.

#2430235

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

The Doc link you shared are the correct ones and I'm not sure why its not working at your end.

Can you please share problem URL and admin access details and let me 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) 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.

#2430313

Hi Minesh, because I did not want my attempts for this to be on the live site, I decided to move my trials to a Local staging site for testing. Do you want me to to send you the files and database by using (https://toolset.com/faq/provide-supporters-copy-site/)?

#2430405

Hi Minesh, I am going to work on creating a testing site that you can access and copy my local database to that test site. I figure that You would be able to give better support by have access this way. When you get a chance, Can you resend the request for access again.

Thanks.

#2430943

Minesh
Supporter

Languages: English (English )

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

*** 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.

#2431145

Minesh
Supporter

Languages: English (English )

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

You are mixing two things here. Both listing posts group by parent and displaying result with custom search are different things.

I've adjusted the view that displays the locations as given under:
=> hidden link

I can see its displaying the correct results group by location.
=> hidden link

#2431149

The problem with the grouping by location is that I want the state to be listed only once, not repeated for every single location.

#2431153

I also need the custom search filter to eventually work so that I can show results by category, like the "Test 1" example.

#2431155

Minesh
Supporter

Languages: English (English )

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

Then you will have to add custom post type States or taxonomy so that we can filter it based on that.

Based on States as post type way:
Then you will have the relationship as: Location => States => Careers
Later we can query posts using view listing all state names and you will have to connect the specific state to careers.

Based on States as taxonomy way:
If you can add States as taxonomy then we will create a taxonomy view that lists state names as parent view and then we will get all careers belongs to that state. You need to attach the post to specific state (term).

#2431159

Ok I thought I may have had to end up going the State taxonomy way. I'll try that method and let you know if I run into any issues.

Thanks

#2431161

Minesh
Supporter

Languages: English (English )

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

I also need the custom search filter to eventually work so that I can show results by category, like the "Test 1" example.
==>
You can not mix both grouping by states as well as custom search as to display group by states we need nested view (view inside view) and we can not place custom search view within the nested view as it will display search form for every nested entry. You have to go with one choice either list posts group by states (again subject to the adjustment to your structure, either use State as post type or taxonomy and attach career posts to it) or go with custom search that will not offer grouping.

#2431163

Minesh
Supporter

Languages: English (English )

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

#2431173

"You can not mix both grouping by states as well as custom search"
==>

I really was hoping that this would be possible. Is there any other possible solutions?

If I have to use only custom search, Can I add in a filter by state dropdown (state field of location - or - "state" taxonomy), so that the user can narrow results by state?

#2431187

Minesh
Supporter

Languages: English (English )

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

You can add the frontend filter to view for the fields or taxonomy that is belongs to the post type you set your view to query by.

For instance - the following view is set to query post type "Careers":
=> hidden link

Then, you can attach a taxonomy "State" to careers post type then you can add a taxonomy filter.

If you have post relationship hagiarchy: Location => State => Careers
Then you can filter posts by related posts. Please check the following Doc:
- https://toolset.com/documentation/legacy-features/views-plugin/how-to-filter-by-related-posts/

#2431205

OK, I'll give it some thought to decide which path I will go.

Thanks