Skip Navigation

[Resolved] Retrieve all posts of the current referenced field

This thread is resolved. Here is a description of the problem and solution.

Problem:

The issue here is that the user wanted to display all the posts using a view that had the same post reference in the post reference field

Solution:
You should be able to add a query filter to your view for the custom reference field and set it to get the value from the current page.

From here you will set the filter to get the value from a shortcode attribute.

So when I add my view to the page I can do this.

[wpv-view name='my-view' reference="[types field='my-field'][/types]"]

So all you need to do is replace "[types field='my-field'][/types]" with the correct shortcode for your reference field.

This support ticket is created 5 years, 4 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by thibaultS 5 years, 4 months ago.

Assisted by: Shane.

Author
Posts
#1346537

Tell us what you are trying to do?
I have created to custom types Courses and Coaches. Course has a reference field to Coach. When i'm displaying a Coach I want also to display all the Course that he coaches

I think I can create a view for that but how can I limit the Courses of only to the current displayed coach ?

#1346623

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Screenshot 2019-09-23 at 3.03.25 PM.png

Hi Thibault,

Thank you for getting in touch.

You should be able to add a query filter to your view for the custom reference field and set it to get the value from the current page. Take a look at my screenshot

As you can see I set my reference field to get its value from a shortcode attribute.

So when I add my view to the page I can do this.

[wpv-view name='my-view' reference="[types field='my-field'][/types]"]

So all you need to do is replace "[types field='my-field'][/types]" with the correct shortcode for your reference field.

Please let me know if this helps.

Thanks,
Shane

#1346847

My issue is resolved now. Thank you!