hey i have a many to many relationship between clinic, doctors and positions and im trying to get the doctors who connected to the current clinic with the specific position
$query = new WP_Query(
array(
'post_type' => 'doctor',
'posts_per_page' => -1,
'toolset_relationships' => array(
array(
'role' => 'child',
'related_to' => 26344,
'relationship' => 'clinic-position-doctor'
),
array(
'role' => 'child',
'related_to' => get_the_ID(),
'relationship' => 'clinic-doctor'
)
),
)
);
but on the results im getting the doctor that is related to the clinic as well but with a different position. how can i fix that?
Hi,
Thank you for waiting and sorry about the delay in getting back.
I've performed some tests on my website and noticed that there are certain limitations involved in your current setup, to achieve what you're planning.
> 'one doctor must be have multiple positions in multiple clinics. For example one doctor is a manager in Clinic A but on clinic B is a visitor doctors'
In Toolset, more than one post-relationship connection can't exist between two posts, which means that if you'll connect 'Doctor A' with 'Position XYZ' in the scope of 'Clinic 1', you won't be able to join the same doctor with the same position, for any other clinic.
A single post-relationship connection can represent or hold information about only two participants, whereas for your requirement, you need three (doctor, clinic, and position).
To overcome this, I'll recommend dropping the 'Position' custom post type and instead add a 'Position' as a custom field, in the intermediary post that is generated as a result of the many-to-many relationship, between 'Doctors' and 'Clinics'.
This way, whenever you'll join a Doctor and a Clinic, you'll have the option to specify what position he/she occupies, which will make all 3 items available, within a single relationship connection.
I hope this makes sense and please let me know if you have any follow-up questions.
regards,
Waqar