plugin development – Update cpt post/page with current date & time if post custom field value match to cpt post/page CF Value

My question is – I have a CPT Post name Company (CF Value – Google) and a Page titled Role (CF V – Engineer). So I want to auto-update with Post published time and date to company post and Role page if published post custom field value match to Google and Engineer.

For example –

  • A Job Post published at 11:30:21PM, 13/09/2021, has two Custom Fields Title Company and Role which has Google and Engineer values.

  • Already published CPT Post Company has a post Google Jobs which has similar CF values Google.

  • Similarly already published page Engineer Jobs which has CF value Engineer.

So my all condition is satisfied because CF value matched, now the code should update Engineer Job (Page), Google Jobs (Post) date and time with recent published post date, time.

Any reference code or help will be appreciated, I want to implement code in my functions.php file.