Site icon Hip-Hop Website Design and Development

What is the best way to set the post category (Custom Post Type) automatically based on the one of the tags assigned to the post?

I have an automated workflow where I use a plugin in Adobe Lightroom Classic (LrC) to publish a collection of photos to my WordPress site. This workflow automatically creates a project post (Custom Post Type), sets the project title based on the LrC collection name, and adds an array of media IDs to a Custom Field within the project which is used by a gallery to display my photos on the front end.

This process also adds WordPress tags to the project post based on any keywords assigned to the photos in LrC.

The problem is that I don’t really have a way to set the project category automatically and so I’m forced to log in to the site and set each category by hand.

Does anyone have some efficient suggestions on how to set the custom post type category based on the tags assigned to the post?

For example, one of the project posts may have the following tags: "Brazilian Jiu Jitsu, Martial Arts, Gi, Competition".

Another project post may have the following tags: "Competition, Bodybuilding, Fitness"
I would like a way to scan through those tags and if the string "Brazilian Jiu Jitsu" is found in the tags then set the post category to Brazilian Jiu Jitsu, if the string "Fitness" is found in the tags then set the post category to Fitness.

I will only really have like 6 different post categories to configure so doing it in my child theme’s functions.php file should be fine.

I just need some help coming up with the code.