Skip Navigation

[Resolved] Displaying a View between 2 CPTs tied together by a Taxonomy

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

Problem:

I have 2 CPTs (Jobs and Location.) I want to show a list of Job posts in the Location CPT. However, they are _not_ bi-directionally linked.

Instead, they both share a taxonomy that is the city/town.

Solution:

It is another many-to-many relationships connected by a taxonomy.

And it is possible within Views, for example:

in a single 'Jobs' post, you can create a post view:

- query posts of "Locations" post type

- Filter by:

Select posts with taxonomy: city/town the same as the page where this View is shown

Relevant Documentation:

https://toolset.com/documentation/user-guides/filtering-views-by-taxonomy/

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

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/Hong_Kong (GMT+08:00)

This topic contains 6 replies, has 3 voices.

Last updated by saint 5 years, 10 months ago.

Assisted by: Luo Yang.

Author
Posts
#1182085

Hi Team,

I am wondering if the following is possible? hidden link

I have 2 CPTs (Jobs and Location.) I want to show a list of Job posts in the Location CPT. However, they are _not_ bi-directionally linked.

Instead, they both share a taxonomy that is the city/town.

So, rather than create a bi-directional relationship between the 'Jobs' and 'Location' CPT, is there a way to display the "jobs" posts in the Location CPT by using the city/town taxonomy values that they both share?

Secondly, if so, would that be more or less performant than just creating a bi-directional relationship between the 2 CPTs?

Please let me know if you need any additional help in clarifying.

Thanks,

#1182104

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Well - I would like to know here, you are displaying Book single post - correct? Or you are displaying a single taxonomy page?

In addition to that, for example, if post X is assigned to "abc" settlement taxonomy term, you want to display all jobs that belong to "abc" settlement taxonomy term - correct?

#1182293

Hi Minesh,

Thanks for your reply.

you are displaying Book single post - correct? Or you are displaying a single taxonomy page?
Yes, that's right - in this scenario, I'll be displaying a Book single post. There will be separate scenarios where single taxonomy pages come into play, but for now this is what I'm trying to accomplish.

if post X is assigned to "abc" settlement taxonomy term, you want to display all jobs that belong to "abc" settlement taxonomy term
Well, I want to display all requests that belong to "abc" settlement taxonomy term AND of a specific "service type" taxonomy term, then show it on the "location" CPT -- which would share the "abc" settlement taxonomy term with "request" CPT.

Please let me know if that was helpful.

#1183382

Hello,

Minesh isn't available, I will take care of this thread.

In your case, it is another many-to-many relationships connected by a taxonomy.

And it is possible within Views, for example:
in a single 'Jobs' post, you can create a post view:
- query posts of "Locations" post type
- Filter by:
Select posts with taxonomy:
city/town the same as the page where this View is shown

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.

#1183397

Thanks, Luo. What is the main difference between these two? hidden link

Does "The current post in the loop" become useful when you have nested Views, so you can have one of the nested Views in the loop use the Loop's post as the "base of reference" (so to speak)?

#1183456

Yes, you are right, option "The current post in the loop" works in a wordpress query loop, for example nested views.

The another option "The post where this view is shown" works in a single post.

#1185288

Thanks, Luo! As a suggestion, it'd be wonderful to see more video tutorials (either by the team, or even by the community) to demonstrate the different use cases that we can do with these options.

I think it'll empower a lot of us to really unleash the power of Toolset. Appreciate your clarification.