Skip Navigation

[Resolved] Listing of at least 1 related item

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 5 replies, has 1 voice.

Last updated by Minesh 1 week, 2 days ago.

Assisted by: Minesh.

Author
Posts
#2815440

Hi.

I have 2 CPT's: "Property" and "Ski station".

Both are related.

I need to add a view on each property page that will display only the Ski Stations that are related to at least 1 published property.

How can I achieve that in legacy mode ?

#2815451

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

I would like to know that what post-relationship you created between the post type "Property" and "Ski station".

Also, I would like to confirm when you display the view on each property page that will display only the Ski Stations that are related to the current property post you are displying or it should be belong to any property post?

#2815453

Hi Minesh

It’s a 1 to many, where properties are Many and SkiStation 1.

#2815501

Minesh
Supporter

Languages: English (English )

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

So, do you want to display the parent belongs to the current property post? if yes:
- you can use the shortcode:

[wpv-post-title item="@your-relationship-slug.parent"]

Where:
- Replace the "your-relationship-slug" with your actuval one-to-many post relationship slug.

#2815510

Hi Minesh.

Properties (many) are the Childs of Ski Station (1).

On the single property pages I want to display a list of all the Ski Stations that are linked to at least 1 property.

Sometimes there is no property at all linked to a ski station. In this case I don't want them in the list. And when a property is linked to a SkiStation I want to display only the ones that are linked to a "published" property.

#2815516

Minesh
Supporter

Languages: English (English )

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

So, if you are not using the classic/legacy view. You can enable the legacy/classic view by followiing the steps given with the following doc.
- https://toolset.com/course-lesson/enabling-legacy-version-of-toolset-views/

Please try to follow the following steps:

- create anothor view namely "property-belongs-skistation" and set this views source (post type) to "Property".
-- Navigate to "Query Filter" section and add the query filter "Post relationship or repeatable field groups owner" and select option "The current post in the loop".
-- Navigate to "Loop Editor" section of this view and just after the [wpv-items-found] shortcode add [wpv-attribute name="parent_title"] and save your view.

- Create a new view namely "connected-skistation" from Toolset => Views and set this view source (post type) to "Ski station".
-- Navigate to "Loop Editor" section of this view and add the view you created above and save the view.

[wpv-view name="property-belongs-skistation" parent_title="[wpv-post-title]"]

Now, at last, on your single property content template, you should try to add the view that should display only the connected-skistation.

[wpv-view name="connected-skistation"]

More info:
- https://toolset.com/documentation/legacy-features/views-plugin/displaying-related-child-posts/
- https://toolset.com/documentation/legacy-features/views-plugin/passing-arguments-to-views/#controlling-the-filter-with-shortcode-attributes