Skip Navigation

[Resolved] Still confused about intermediary post for post to post relationship

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

Problem:

Two post types:

- projects

- project-category

1) setup many-to-many relationship between above two post types

2) In a single "projects" post, you are going to display other related "projects" posts.

Solution:

I suggest you setup a custom taxonomy, for example: "projects-project-category", and register this taxonomy to both post types, it can also setup another many-to-many relationships.

For example:
https://toolset.com/forums/topic/still-confused-about-intermediary-post-for-post-to-post-relationship/#post-1236813

Relevant Documentation:

This support ticket is created 5 years, 7 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 – 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/Hong_Kong (GMT+08:00)

This topic contains 8 replies, has 2 voices.

Last updated by JamesK4399 5 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#1235903

I need to show 2 projects that are similar to the project being displayed. All projects are assigned a project category. I already hung 3 "Featured" projects off the project-category post type. I could create another relationship of "Similar" to the project-category but couldn't figure out the link to the project.

The filter would be 1 of the 3 similar projects in this project's parent project-category.

Hope that makes sense. I read the songs, albums and listing post but it didn't include instructions to make the link.
https://toolset.com/faq/how-do-i-associate-one-child-with-several-parents-of-the-same-type/

Thanks, Jim

#1235904

I also tried to add the Project ID of 2 projects as custom fields to a project. I couldn't figure out that filter either. Pull the IDs and then get the Project of that ID?

Is that a possible solution?

#1235952
filters.JPG

Dear Jim,

Please elaborate the questions with more details:
How do you setup the post types and relationships?

I assume we are talking about this case:
1) One post types: projects
2) A custom taxonomy: project-category, registered to above post type.

In a single "project" post, you are going to display other related "project" posts on project-category.

If it is, it is possible with view, you just need to setup a post view:
1) Query "projects" posts
2) Filter by:
Select posts with taxonomy:
project-category the same as the page where this View is shown
See screenshot filters.JPG
3) Enable the option "Don't include current page in query result"
4) In section "Loop Editor", within view's loop, display the "project" post's information

More help:
https://toolset.com/documentation/user-guides/filtering-views-by-taxonomy/
Value set by the current page where this View is shown:
The View is always inserted somewhere. That page where the View is inserted is responsible for setting the taxonomy term. This is good when you want the same View to return different results, according to the page it’s inserted to.

#1236383

Hi, Luo Yang.

I think you understand what I want to do. I already have a custom post type called project-category and I have "hung" several different projects to it for pieces of the site. For example, airports is a project category and I have a list of projects that are airports and 3 featured airport projects which show up on the very top of hidden link

If you are on that page and click "Los Vaqueroes" than you'll go to the project details page. I tried to write a view that would get the "similar projects" from the project category and got lost. I have it returning the first 2 projects in the database which aren't really what I need. The format is perfect with the pictures and links so I just need to hook up the correct projects.

So I created another CPT called similar projects which has a many to many relationship to projects. Then I created an entry named "Los Vaqueros" and I added the 3 similar projects including "Los Vaqueroes". I got lost in that view as well.

I will take a look at the instructions you sent. If you have other ensights in the meantime I'd love to hear them.

Thanks again for the excellent customer service you guys have given me.

#1236813

Thanks for the details, I assume we are talking about this case:
Two post types:
- projects
- project-category

You are going to:
1) setup many-to-many relationship between above two post types
2) In a single "projects" post, you are going to display other related "projects" posts.

If it is, I suggest you setup a custom taxonomy, for example: "projects-project-category", and register this taxonomy to both post types, it can also setup another many-to-many relationships.
Edit posts:
- edit each project-category post, setup the "projects-project-category" term same as "project-category" post title
- edit each projects posts, setup the "projects-project-category" terms as related "project-category" post title

Then in a single "project-category" post, you can display the related "projects" by taxonomy "projects-project-category", as I mentioned above:
https://toolset.com/forums/topic/still-confused-about-intermediary-post-for-post-to-post-relationship/#post-1235952

Create a post view:
- Query "projects" post
- filter by:
"projects-project-category" the same as the page where this View is shown

Same as above, in a single "project" post, you can also get related "projects" posts with a single post view:
Create a post view:
- Query "projects" post
- filter by:
"projects-project-category" the same as the page where this View is shown
- Enable the option "Don't include current page in query result"

#1243815
similar-projects.png

I went through your steps and realized that it really isn't related to a category.

This is what I tried.

I created a custom post type called "Similar Projects" which is a many-to-many to projects.
Similar Projects [*] << Similar Projects >> Projects [*]
So then I created a new entry "Similar to Maxwell Farms" to which I added 3 park projects.

Maxwell Farms Regional Park
Marquam Nature Park Trails Planning and Design
Cooper Mountain Nature Park

Page is:
hidden link

So if I'm on the Maxwell page I want to see Marquam and Cooper in the similar projects section.

The filter is what I believe is tripping me up.

The view has projects as type and in the relationship of Similar Projects. I tried all the settings and don't get the desired results. It is only when I say specific similar project that I get the desired list.

I sent an email with login information and you can reset password if necessary.

Thanks,
Jim

#1243886

Dear Jim,

I did not get the email, please provide your website credentials in below private message box, also point out the problem view URL, thanks

#1245566

Thanks for the details, I can log into your website.

Since you are using many-to-many relationships, so in your case, it needs a nested view, I have done below modifications in your website:
1) Edit project post "Maxwell Farms Regional Park Master Plan and CEQA Documentation":
hidden link
in section "Similar Projects", click button "Connect existing Similar Project", connect it with list-similar-project post:
Projects Similar to Los Vaqueros

2) Create parent post view "parent view - related list-similar-project posts":
hidden link
- Query "Similar Projects" (list-similar-project) posts
- filter by:
Select posts in a Similar Projects relationship that are related to the Post where this View is shown.
- in view;s loop, display below child post view

3) Create child post view "child view - related project posts":
hidden link
- Query "Projects" posts
- filter by:
Select posts in a Similar Projects relationship that are a related to the current post in the loop.
- in Views loop, display project information, for example post link:
[wpv-post-link]

4) Edit the layout "Layout for Project Details", in the bottom of content, display the shortcode of parent post view:
Nested view here:
[wpv-view name="parent-view-related-list-similar-project-posts"]

Tested it in front-end:
hidden link

It works fine, please check if it is what you want. thanks

#1257829

My issue is resolved now. Thank you!