Skip Navigation

[Resolved] Display a list of custom post types with content of related posts / post types

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 0 reply, has 1 voice.

Last updated by Minesh 7 months ago.

Assisted by: Minesh.

Author
Posts
#2791320
filter not working.jpg

Tell us what you are trying to do?
I am building a website for my sports club. I created custom post types for trainers, types of sports, sessions and places (where the session are held). I created post relationships: trainers-sessions(1-many), sports-sessions(1-many).
Now I am trying to create a list of all sessions on one page: Sorted by the types of sports (A-Z) and after each sports name (as a heading) a list of all sessions that belong to this sport (like rows in a table). Each entry/row should show the custom fields of the session post type (weekday, hours, name of the session) plus the related trainer and the related place/location.
I managed to create a view/loop that outputs all sessions with the corresponding fields BUT I cannot "group" them by type of sport. I tried to create a loop that outputs all sports in alphabetical order and nest another loop inside that puts out the sessions. I can do that, but i cannot filter the session by the sport of the "parent" loop item. I tried to filter by post-parent / "parent is the current post in the loop" but that didn't work.

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site?
hidden link

#2791467

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

First let me tell you about custom search (where you can build the view and add frontend filters using which users can filters the view results using custom fields, taxonomy):

When you build the custom search, you can add frontend filter or query filter for fields or taxonomies that is directly belongs to the post type you set your view to query.

Having said that consider the following structure:
- post type X with custom fields (a,b,c) and taxonomy (aaa,bbb)
- post type Y with custom fields (p,q,r) and taxonomy (ppp, qqq)

So if you build a custom search for post type X, then you can add frontend filters for custom fields (a,b,c) and taxonomy (aaa,bbb). You can not filters view results using custom fields (p,q,r) and taxonomy (ppp, qqq) as those are part of post type Y.

It seems you already achived grouping for sports as you are using nested view.

If you can share problem URL and admin access details and tell me what is your expected results with few screenshot/video I will review the structure and see if any posssible workaround I can offer you.

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

#2792437

Minesh
Supporter

Languages: English (English )

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

When I try to login using the admin link you shared I can see the following message:

Service Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

Can you please send me working site so that I can login to the site.

#2792469

Can you please check again. It must have been a temporary problem. I can access the website as normal.

#2792613

Minesh
Supporter

Languages: English (English )

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

Well - what is your suggested layout.

I checked the page you build and I see that you crated two block views and you added view inside view (nested view). We do not recomond to use Block based nested views. As you may find it will break at anytime as nested block view is not supported.

So, in your case I belive you will require to build view in classic mode.

Sports 1
- Related Trainers information (title) and location belongs to Sport 1
- Then, display table for sessions post type information which you already did.

Is that correct or you may share screnshot how you want to display the inforamtion as it depends how exactly you want to display the inforamtion.

#2792617
Screenshot 2025-01-17 113103.jpg

Please see screenshot

#2793164

Minesh
Supporter

Languages: English (English )

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

Can you please check now: hidden link

On the page where you added your view:
- hidden link

With the first view at top of the page:
--- I've added the post-relationship filter to filter the post with your relationship:
Screenshot - hidden link

Filter by post relationship or repeatable fields group owner
Select posts in a Relation Sportarten Einheiten relationship that are a related to the current post in the loop.

--- I've also added the condtional block and added the condition that will only display the parent post title if the (child) view has results. Within conditional block I've added the "Fields and Text" block and added the shortcode that will catch the parent post title with link we pass from the 2nd view.
Screenshot: hidden link

[wpv-attribute name="parent_title_link"]

With the second view at bottom of the page:
--- I've removed the view block you added and added the "Fields and Text" block and added the 1st view using the view's shortcode:
Screenshot- hidden link

[wpv-view name="testview-sportangebot-gesamt" parent_title_link="[wpv-post-link]"]

As you can see we are passing the sports as post title link with the shortcode attribute "parent_title_link" and we catch the value of "parent_title_link" using the [wpv-attribute name="parent_title_link"].

So basically, 2nd view on the page is parent view (that query parent post type) and 1st view you have is the child view (that query child post type - just to give you understanding).