Skip Navigation

[Closed] Creating a View with Post Relationship using M2M

This support ticket is created 4 years, 1 month 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: Africa/Casablanca (GMT+01:00)

This topic contains 19 replies, has 3 voices.

Last updated by Jamal 4 years ago.

Assisted by: Jamal.

Author
Posts
#1851363

JSG
2020-11-20 14_44_52-View_ Job Posting3 - SkillZDr Sports.jpg
2020-11-20 14_32_06-Edit View ‹ SkillZDr Sports — WordPress.jpg
2020-11-20 14_33_32-Edit View ‹ SkillZDr Sports — WordPress.jpg
2020-11-20 14_33_47-Edit View ‹ SkillZDr Sports — WordPress.jpg
2020-11-20 14_41_57-Edit View ‹ SkillZDr Sports — WordPress.jpg

I have a M2M set up with two Custom Post Types
Job Location
Job Description

I have been successful in setting up the Search post Relationship with the two post types as ancestors

For some reason, my results do not post properly. I'm inserting the field using "A post related to the current post, set by a Types relationship " If offers three options, The post types and the combined M2M post type.
None of these selections are yielding the correct results.

I have attached some scene shots as a reference

#1851665

Hello and thank you for contacting the Toolset support.

To better assist you with this issue, I think that I'll need more details and access to your admin area to check this closely.

I would like to know, this search is meant to search what custom post type? From a functional perspective, what filters would you like to offer and what results would you expect?

If you agree to share access to your website, I already set your next reply as private to let you share credentials safely. ** Make a database backup before sharing credentials. **

#1855525

Before going further with analyzing this issue, I must say that you are using outdated versions of the Toolset plugins, We may be investigating issues that were already fixed on previous releases.
Check our changelogs:
- Toolset Types: https://toolset.com/download/toolset-types/#changelog
- Toolset Views: https://toolset.com/download/toolset-views/#changelog

I suggest that you perform an update on a staging site and we can check the issue on it. You can also test your site before performing the update on the live site.

** Do not perform the update on the live site without taking a full backup **

As you have the latest version of WordPress you can update the plugins manually, because there seems to be an issue with the current installer version in your website and our update server. hidden link

After the update, go to Toolset->Settings->General(tab)->Editing experience. Make sure that the legacy editor is active.
Go also to Toolset->Relationships to trigger the relationships migration if it was not performed silently.

#1856983

JSG

Thank you very much for what you have done. I have done the updates and ran the view again but still see the issue. Can you help with this?

#1857679

I could not find a page where the view is being used, so I created a private page and added the view to it and I tried to check but everything seems correct to me, the view does filter. Can you elaborate more on the issue or explain a scenario in steps:
1. I go to xxx
2. I do xxx
3. I expect to have xxx
4. Instead I get xxx

#1859395

JSG
2020-11-27 10_34_03-JTS Test - SkillZDr Sports.jpg
2020-11-27 10_33_39-JTS Test - SkillZDr Sports.jpg

Thank you.

1. I go to the test page you created /jts-test
2. I do select "Brentwood, TN 37027"
3. I expect to have the two jobs associated with Brentwood in the output. (I do see them filtered in the Job Details)
4. Instead I get the additional job posted for Franklin.

The same thing happens when I select Franklin. The Filter works but the output shows the same job listed in both cities.

#1859799

I just want to let you know that I am still working on this issue. I don't think that what you try is possible, because ancestors make send in a hierarchical type of relationship. For example, CPT A is related to CPT B in a one-to-many relationship, and CPT B is related to CPT B in a one-to-many relationship, we can then filter posts from CPT C based on the parent(ancestor) CPT B and its parent(ancestor) CPT A.

I'll check this with our 2nd Tier and get back to you.

#1860737

JSG

Thank you for looking into this.

Again the goal is:

Many Job locations
Many Job descriptions

So each job can be in many cities and each city can have many jobs.

#1861343

We have pushed a new release of the plugins today and I would like to check the issue on them. For that reason, I wonder if it is possible to take a copy of your website for my local testing. The copy would also be useful in case I don't find a solution and I need to escalate the ticket to our 2nd Tier.
Please let me know if it is ok with you to take a copy of your website?

#1861641

JSG

Yes, no problem. You can copy it. Let me know if I need to do anything to help you out.

#1862795

I just want to let you know that I am still working on this issue. Below what I have tried so far, but I am still not able to get a working copy locally:
- Try Duplicator, failed.
- Try All In One Migration, copy packaged but failed to build locally(stuck at 99% progress).
- Try a Database Duplicator copy. Failed to work locally.

I'll try again with the All In One Migration export and get back to you as soon as possible.

#1862887

JSG

Thank you.

#1863641

Minesh
Supporter

Languages: English (English )

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

Jamal is on holiday today, he will get in touch with you as soon as possible once he back to work.

#1865539

Minesh has tried to filter intermediary posts by both sides(right, left) of an M2M relationship in his test site and he got the same results(posts are not filtered with the second dropdown/filter, even if the second dropdown is filtered by the first one). hidden link
You can log in with demo / Admin@999

So, I reached out to our 2nd Tier and he confirms that we can't currently filter a view with more than one relationship. Which means that, in an M2M relationship, we can filter the parent post type by the child post type or the child post type by the parent post type, we can filter the intermediary post type by the parent or child post types, but we can't filter the intermediary post types by, both, the parent or the child.

"Ancestors" do not make sense when talking of the intermediate post type and the left and right sides of an M2M relationship, it only makes sense when you chain together a series of one-2-many relationships, so you have parents and grandparents, etc. I built a test for it here hidden link
You can log in with the following URL to check it on the backend hidden link

Discussing this with the 2nd Tier, we wonder why would you like to filter the intermediary post type by both post types of the M2M relationship? Because, in the end, you will always get one post in the results, because we can't connect two CPT in an M2M relationship more than one time.
Can you elaborate more on what you are trying to do?

Finally, I would like to add, that we can achieve filtering by two relationships, but that would need custom code. Check this previous ticket, which is a bit similar(filtering with two relationships). Our colleague, Christian, has shared an example custom code that handles a different case(not using filters for both relationships) https://toolset.com/forums/topic/filtering-view-based-on-relationship-with-two-parents/

Our developers are planning to add support for multi-relationships filters in the future, but we do not have an ETA for when it will be built.

I hope this explains a little the limit of views filtering, and how ancestors should be used. Let me know if you have further questions.

#1865823

JSG

"Discussing this with the 2nd Tier, we wonder why would you like to filter the intermediary post type by both post types of the M2M relationship? Because, in the end, you will always get one post in the results, because we can't connect two CPT in an M2M relationship more than one time.
Can you elaborate more on what you are trying to do?"

Here is what we would like to be able to achieve.
A user looking for a job can search by two methods. One, by location and or by job type.

Here is a use example:
The user lives in Buffalo and is a tennis coach. They would search for jobs in Buffalo, to see what jobs are avalible. They can then scroll through the jobs and see if there is a tennis coaching job.

The other option is he wants to see what tennis jobs are avalible nationwide. He then clicks on Tennis and can see which cities have jobs for tennis coaches in them.

Please let me know if this is possible.

The topic ‘[Closed] Creating a View with Post Relationship using M2M’ is closed to new replies.