Skip Navigation

[Resolved] Connect Employee and Specialisme posts, part 2

This support ticket is created 6 years, 2 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 13 replies, has 2 voices.

Last updated by Christian Cox 6 years, 1 month ago.

Assisted by: Christian Cox.

Author
Posts
#1137743

Hi Christian,

I am still not "happy" with how it work. I am able to get the employees connected to the post but it is a "manual" task where i think it can be much easier. And think it is not working how you explained me. Tried again the whole day but i just don't get the view working without manually add the employee(s) to each post. So for moment i added the employee "manually" to each post. But as there are 45 employees and hundreds of posts it will be a lot of work to use it in real live environment.

I am doing it now on my "real" project like this ;

- Werknemers, what means where are all employees with there own speciality.
- Vakgebieden, are the posts where i connect the werknemers (with there own speciality)

img; "Vakgebieden view", here you see that i can manually connect the employee to the post of vakgebieden.
img; "Choose werknemer (employee)" here i must find the employee.
img; "result", and it show the employee in the post.
img;"vakgebieden olenz" is the costume field from werknemer (employee) shown in the post vakgebieden.

Again it "works" but i am sure it is not using the "power" of toolset or am i wrong and means i have to add each employee to each post ?? and not choose speciality and all employees are shown from that specially in ones in the post ?

img;"relationship m2m is the m2m relation as suggested.
img;"view look" how i made the view
img;"template for view" how the view is made.

As you can see in image "choose werknemer" there is a option for "specialisme" but i always must choose a name with it and even when i don't choose on of the specialisme it still will show the werknemer (employee) in the post.

But i am sure i do something wrong here or i miss a important point in your explanation and there is a fantastic solution with 1click in the post (specialisme) and will show all specialist of that post.

Hope you can help me out here

cheers
Marcel

#1137751

So for moment i added the employee "manually" to each post. But as there are 45 employees and hundreds of posts it will be a lot of work to use it in real live environment.
Either you must connect the Employees in each Specialty post, or you must connect Specialty posts to each Employee. If you don't want to do this in wp-admin, you can also import post relationships in a CSV format or use the PHP API to do this programmatically. We have documentation about importing post relationships and APIs here: https://toolset.com/documentation/user-guides/importing-content-from-csv-with-post-relationships/
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/

As you can see in image "choose werknemer" there is a option for "specialisme" but i always must choose a name with it and even when i don't choose on of the specialisme it still will show the werknemer (employee) in the post.
The checkbox is for choosing an employee role in a specialty. This allows employees to have different roles in different specialties. For example, Employee John is Administrator for Specialty Manufacturing, but Employee John is Technical Director for Specialty Banking.
- Create one Employee post "John"
- Create two Specialty posts, "Manufacturing" and "Banking"
- Now connect John and Manufacturing and choose the checkbox "Administrator". You can connect these posts by editing John, or by editing Manufacturing.
- Then connect John and Banking, and choose the checkbox "Technical Director".
- Now Employee John is related to Manufacturing and Banking, with different roles in each relationship.

Now you can create a View of Employees related to each Specialty, and show the Employee's role. Insert this View in the template for Specialty posts. Check this out, I set up a demo:
hidden link
hidden link

Please create an account at discover-wp.com using the email address associated with your Toolset account. I can give you access to the wp-admin area so you can see how it's set up, and explain things more clearly.

#1137756

Hi Christian account is made in discover-wp.com

#1137758

Check your email, an invitation should be on the way now.

#1137812

Hi Christian,

Thanks for the explanation and the example, but i think this is what I have for the moment as explained or i still don't get the picture. Sometimes is difficult to explain it by mail 🙂

And i think there is a other way as i see so many options in toolset so i don't give up 🙂 To make 1 post and then connect 15 persons manually it is a lot of work.

Let me try again to explain with your example ;

In Employee (what is in my project Werknemers) i would create a custom post field called "Specialties" with banking and manufacturing as option. So in Employee are all employees including there Speciality with a checkbox.
And then when creating a new post Specialties, choose one of the Specialities (or both) instead of manually connect the Employee as we do now (see my image vakgebieden olenz where you see the option)

Hope it is more clear now.

#1137838

And then when creating a new post Specialties, choose one of the Specialities (or both) instead of manually connect the Employee as we do now
Okay let's discuss your example, because I don't think you understand that it's still a lot of work. Let's say you must create a new Specialty "Construction". Now you have 3 Specialty posts - Manufacturing, Banking, and Construction. How do I connect Employee John with Specialty Construction? I must edit John's profile and select Construction manually somehow. Now what if there are 200 Employees who have the Construction specialty? I must manually select Construction in 200 Employee profiles.
So in either case, a lot of manual work is required. In fact, your example requires MORE work because it requires an additional custom field in two post types.

#1137855

Hi Christian,

I am sure my explanation is not good. Sorry about that. Is it possible to do a live video call so i can show you ? With Category i make it in few seconds using views and have what i need. But i can't believe that this is the correct way of using Toolset all-do it has the result i want, show related employees to the post . But it means that i must put for each post the "costum field" and the category and "big change" of mistakes.

Cheers
Marcel

#1138196

I understand, you're talking about using a taxonomy term to connect Specialties and Employees. With a Specialty post type and a Specialty taxonomy it would be much faster to set up, because you can bulk-edit several Employees at one time and add a Specialty taxonomy term. However, it means Employees cannot have different roles in different Specialties. If an Employee can only have one role, then a custom taxonomy is easier to set up. However, if one Employee can have different roles in different Specialties, then it requires a post relationship with a custom field on the intermediary post. This is slower, because there is no bulk-edit for post relationships. You must add them individually, or import them from a CSV, or use the post relationships API to connect posts.

So it is important to know if one Employee can have different roles in different specialties. Can John be an Administrator in Banking and a Technical Director in Manufacturing? Or must John be the same role in all his specialties?

#1138257
Custom field filter vakgebieden olenz.png
view employees.png

Hi Christian,

Luo responded on the "other" ticket https://toolset.com/forums/topic/connect-post-type-employee-fields-and-post-type-specialisme/#post-1138229 he has other approach.

And yes, to use the taxonomy will get me other problems because you are right employees have one role, but i use more costume fields where the are more different "roles" that i must use in the project later so use taxonomy is not a good option.

"Okay let's discuss your example" think that you are not right. As for example employee has now status A and tomorrow he is B. In my approach it means that i change the custom field to A to B in it will show in the post the new setup.
If i use the "relation" post it means i have to go 1 by 1 and change it. And on each employee i just choose the role in mine opinion.

Like i said in my previous post, the idea in one sentence is, Show related employees in a post (from a different posttype) based on custom field. In other words the custom field is shown in both custom post type.

Luo suggests the following

"If it is, it is possible, for example:
in a single "custom-post-type" post, you can get it's "vakgebieden Olenz" field value with Types shortcode:
[types field='vakgebieden-olenz' separator=', '][/types]

pass it as shortcode attribute of below view, for example:
1) Create a post view, query "Employees" posts, filter by:
Select items with field:
vakgebieden Olenz is a string in VIEW_PARAM(vo)

see screenshot checkboxes-filter.JPG

2) In the single "custom-post-type" post, display above view's shortcode like this:
[wpv-view name="connect-post-type" vo='[types field='vakgebieden-olenz' separator=', '][/types]']"

I did the steps but still shows all employees. (see images) normally only 2 have the correct field option.

Tried now for few hours but still not what I expected. Hope you can open the right door for me and show the related employees.

Cheers
Marcel

#1138326

"Okay let's discuss your example" think that you are not right. As for example employee has now status A and tomorrow he is B. In my approach it means that i change the custom field to A to B in it will show in the post the new setup.
You are talking about changing a custom field. Where is the custom field? It must be on some post type. This means it is either on the Employee post, or on the Specialty post.
- If it is on the Employee post, then one Employee can only have one role in all Specialties. John is always an Administrator. John can have no other role in any other specialty.
- If it is on the Specialty post, then all Employees will have the same role in that Specialty. John, James, and all other Employees associated to Manufacturing are Administrators for Manufacturing. There can be no support persons or technical directors for Manufacturing.

#1138364
vakgebied.png
werknemers.png

Hi Christian,

Thanks for the reply. The custom field is on both, see images. Make custom post > choose vakgebied and show related employees (werknemers) in the post.

Looks like it will be manual task then. Make post and find the employee. Somebody will have a new job then 🙂 will be lot of work. What happens if employee get new function ? or leave Must we manually change each post ?

Cheers
Marcel

#1138400

The custom field is on both, see images.
Okay so you can only choose one role for an Employee, and you can only choose one role for a Specialty! That's not what you need! You cannot use just one set of checkboxes for "role". You need one set of "role" checkboxes for EACH SPECIALTY. If John has two Specialties:
Employee "John"
- In Specialty "Business"
-- Choose role: Administrator | Technical Director | Supporter
- In Specialty "Marketing"
-- Choose role: Administrator | Technical Director | Supporter

See? You cannot use just one set of checkboxes. You need multiple groups of checkboxes.

What happens if employee get new function ? or leave Must we manually change each post ?
If an employee gets a new role in a Specialty, edit the Employee post. In the Post Relationships editor, find the entry for this Specialty. Click edit, and change the role. If an employee leaves, trash the Employee post.

Check the post relationship guide here for an example with Albums, Songs, and Track Numbers.
https://toolset.com/documentation/post-relationships/how-to-set-up-post-relationships-using-toolset/
Albums = Employees (John)
Songs = Specialties (Business, Marketing)
Track Numbers = Roles (Administrator, Tech Director, Supporter)

#1140572
shortcode inside post.png
connected employee.png
post example.png

Hi Christian,

How are you ?

Created the "many" relationship, to connect employees to "normal" posts and post types. But it is not working as i expected. When create new post, i don't get the info or the "connected" employee with Dynamic content. When i create a view it shows the employee based on the relationship made but i hope this is not the idea.

I expect to choose dynamic content (with elimentor) and show the info related to the post. What do I do wrong here ? Also when i place short code in the post nothing is shown.

New threads created by Christian Cox and linked to this one are listed below:

https://toolset.com/forums/topic/elementor-dynamic-content-and-related-posts/

#1140738

Hi, I'm doing well thanks! I hope you are well too. I would like to keep this ticket focused on how to connect Employees and Specialties. I have split your question about Elementor and dynamic content into a separate ticket, since it's really a different topic. We have a one topic per ticket policy. Thanks for helping us keep the forum organized.