Skip Navigation

[Resolved] How to create a view which uses the repeating field of another post type

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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Karachi (GMT+05:00)

This topic contains 4 replies, has 2 voices.

Last updated by Waqar 11 months ago.

Assisted by: Waqar.

Author
Posts
#2675861
Screen Shot 2023-12-23 at 10.24.21.png

I have TWO custom post types containing names and information about professors.

Faculty Profile
Strategy Group Profile

Faculty Profile has a repeating field "Publications".
And obviously, we use a View to output the repeating field in the Faculty Profile Single Post template

Strategy Group Profile has a Post Reference Field where we can relate each professor who is part of the Strategy Group back to their respective Faculty Profile.

I want to output all the "Publications" data from the matching "Faculty Profile" post into the "Strategy Profile" post.

How do I do that?

FYI I am using the legacy Views with Short Codes, NOT the Views Block or Gutenberg.

I am using a Query Filter but I suspect it's not right, because it seems to be outputting ALL publications rather than just the publication for each single professor.

#2676089
parent-view.png

Hi,

Thank you for contacting us and I'd be happy to assist.

Because you mentioned 'we use a View to output the repeating field in the Faculty Profile Single Post template', I'll assume that the "Publications" are stored as a repeatable field group with the 'Faculty Profile' posts and not as a repeating field.

To achieve what you're planning, you'll need to two separate views:

1. The parent view will be 'View to show the related Faculty Profile'. It will be set to show the 'Faculty Profile' posts, with a post relationship query filter, to show only the posts based on the related professor coming from the post reference field.
( example screenshot attached )

This will view will be directly placed in the template for the single 'Strategy Group Profile' post.

2. The child view will be 'View to show the related Publications'. It will be set to show the 'Publications' posts (repeatable field group), with a post relationship query filter, to show only the posts based on the repeatable field group relationship, with respect to 'The current post in the loop'.

This view will be placed inside the loop of the parent view from step 1.

I hope this helps and please let me know if you need further assistance.

regards,
Waqar

#2676177
query-filter-parent-view.png
content-selection-parent-view.png
repeatable-field-faculty-post-type.png

Thanks for your reply.

Yes, "Publications and Papers" is a repeatable field group within the Faculty Profile custom post type.
(see screenshot)

To be honest I am a bit lost.

IF I choose the Content Selection- "Repeatable Field Group: Publications and Papers"
and the Query Filter "Specific: Faculty [professors name manually selected]"
I get exactly the output that I want.

But obviously, that's only going to work for a single professor.
I need something that is going to be dynamic and work for the Strategy Group Profile template.

I don't understand how to use parent/child nested views as you've described above.

Would it be possible to give Admin Access for you to take a look at my Views setup?

#2676283

You can make the view's query filter dynamic by selecting the option 'The current post in the loop'.
( screenshot: hidden link )

This way the parent view will be setting the scope of the professor and this child view will be using that scope as a source to fetch the relevant publications.

You're welcome to share temporary admin login details, in case you still face any difficulty in making this work.

Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.

#2676390

Thank you for sharing the access details.

I made the following two changes, to make this work, without an extra view:

1. In the query filter of the view 'Publications and Papers - IIS Profile - Repeating Field', I changed relationship filter it to the option: The post with ID set by the shortcode attribute: wpvrelatedto
( screenshot: hidden link )

This way, the view will look for the ID of the target post in the shortcode attribute 'wpvrelatedto' to show the related post.

2. Next, in the view's shortcode that is used in the template for the 'IIS Profiles', I passed the ID of the related faculty post through the 'Published Work' field using the shortcode [wpv-post-id item='@published-work.parent'].

The complete shortcode for the view with the 'wpvrelatedto' attribute looks like this:


[wpv-view name="publications-and-papers-iis-profile-repeating-field" wpvrelatedto="[wpv-post-id item='@published-work.parent']"

As a result, the set up to show the related post's publication, becomes dynamic.

#2676448

Brilliant work! Thank you!