Skip Navigation

[Closed] Post view conditional on many-to-many relationship of another post

This support ticket is created 4 years, 2 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.

Our next available supporter will start replying to tickets in about 3.96 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 6 replies, has 2 voices.

Last updated by Nigel 4 years, 2 months ago.

Assisted by: Nigel.

Author
Posts
#1765599

I'm building a 'my account' page with some complex functionality, and struggle with finding a way to display the parent post of another post type.

More specifically:

The user is first asked to create a single 'member profile' (post type) to be displayed on the website. I have done this by creating a view limited to show only one 'member profile' - and if there are none submitted yet, then it displays a form for creating it.

Once they have created this, they are shown this member profile (I've designed a preview using content templates).

So far so good. Now the second step is for them to create a project.

Each project can have multiple team members. I've created this as a many-to-many relationship, since some members could potentially belong in several projects (though, this would be done in exceptional cases - I'm not designing the front-end so that users can do this themselves).

Users are now provided two options - they can either use a relationship form to connect their profile to an existing project (one already uploaded) or they can create a project for their team (when this does not yet exist).

I have been able to create both these forms, and currently display them when there are no projects found. The challenge is, however, that I cannot figure out how to display the project that is connected to their member profile! I could, of course, show the project that the user have created themselves - but that would not display this project for members that have used the relationship form to connect to an existing project.

I've tried to 'nest' the view for projects within the 'member profile' view, at the bottom of the content template for the user profile preview in the view - but it does not work to choose to display projects related to "projects in the loop" (probably because it is essentially a view within a view).

Apologies for the long message, its a bit tricky to explain. Any pointers would be really helpful! To summarise: I am trying to create a view that would display projects in any relationship to the currently logged in users 'member profile'. I cannot use post author query, since some team members connect to existing projects.

#1765667

It will also be relevant for other post types Im planning on creating for an online programme - using a similar logic of "unlocking" new videos once they have submitted the particular task that week. I would like the entire group to be able to move to the next video as long as at one team member have submitted their work, so this would be really valuable advise.

#1765841

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Screenshot 2020-09-04 at 07.36.33.png

Nested Views should work (I assume you are using legacy Views rather than the Blocks editor for Views, as it does not yet support nested Views).

This is on the My Account page, yes?

So you need a View to query the profile post of the current user (you probably already have one) to set that profile post as the context.

In the output section of that same View (within the items found section) you then insert the second View to display the project(s) related to that profile post.

Which means in that second View, to display the project, you add a relationship Query Filter to show posts from the profile-project relationship related to the current post in the loop (the context from the outer View).

Assuming you have sample data set up as you describe then that is the solution, if you could confirm.

#1766281

Hi Nigel,

Thanks for taking the time to look at my challenge!

"Which means in that second View, to display the project, you add a relationship Query Filter to show posts from the profile-project relationship related to the current post in the loop (the context from the outer View)"
- this is exactly what I have been attempting to do! I thought if I added the view put in a view, then it would pick up the parent of the post it is nested within?

"Nested Views whould work (I assume you are using legacy Views rather than the Blocks editor for Views, as it does not yet support nested Views)."
- Im using the divi editor, so perhaps this is where the issue lies? Do you think this is the problem, and is there a workaround here?

Thanks again!

Andrea

#1766413

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

It should work.

I'm not sure if Divi could be the problem.

Can you make a simple test without using Divi and see if it works? If it does, and Divi is the problem, then I'll have to think about a workaround.

#1766911

Hi Nigel,

Thanks for the followup.

I tried a test with twenty twenty theme and got the same problem! Is there another way I could display the parent if the user's profile post (which will be one per user) is already connected to this parent?

#1767773

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Not really, that's how to do it.

Maybe I'm missing something from the description of your setup.

Can I take a look at your site and see for myself? I may be able to spot the problem.

I will mark your next reply as private so that I can get log-in credentials from you—you may want to create a temporary admin user for me to use that you can later delete. And be sure to have a current backup of your site.

The topic ‘[Closed] Post view conditional on many-to-many relationship of another post’ is closed to new replies.