WAIT: Query Question - Relationships in query?

Hi there,

I’m having some issues with a pretty (imo) difficult query question.

I’m building an Account section and my wordpress environment is set up with the following CPT’s and relations:

I have 2 CPT’s.

  1. Repairs
  2. Companies

There’s 2 relations:

  1. Company > User
  2. Repair > Company

I want to show all the repairs of the company the user is linked to.

How would I go about creating this query? Nothing I do seems to work properly. I’ve also tried using the meta query, but without luck…

I’ve tried the following meta query:
image

Thanks in advance!

Can a company have more than 1 related user?

Can a company undertake more than 1 repair?

Hi @Sridhar,

Yes, a company can have up to 2 related users, however, a user can only be related to 1 company at a time.
A person (who is linked to the company) can send in as many repairs as they’d like.

The setup i’ve tried is:
Query for post type repairs
– nested query for relationship

Here’s the relationship:

Bumping this as I still don’t have a solution to this.

Small update:
I’ve created a single template on the company post type with a query for the relationship to see if that returns all the repairs of that company. This works.

However, now the issue is still that I want to show the amount of repairs this company has…