Wordpress custom post type permalink parent/child but different types

admin

Administrator
Staff member
In wordpress I created 2 custom post types: company and offer
offers are linked to companies with a customfield called companyname.

So if an offer called 'My offer' is linked to Company 'ACME', both posttype contain a customfield called 'companyname' with value of ACME.So far no problem.

I registered both custom posttypes with a default slug 'company' and 'offer'

The shop permalink url is now: www.mywebsite.nl/company/acme/
The offer permalink url is now: www.mywebsite.nl/offer/my-offer/

What I want is the offer permalink is changed to www.mywebsite.nl/company/acme/my-offer/

I searched a lot through filters/action/hooks (and stackoverflow), but I cannot find a solution. I even tried to make the post-types hierarchical, but in an 'offer' posttype I cannot make a 'company' posttype the parent.

How can get the url structure I need?