I have a CPT called jobs and a page named Job Apply. I am trying to achieve something like below url:

http://example.com/job-slug/apply

Where, job-slug can be any job. i.e Programmer, Developer etc..

On clicking job’s apply button, it should open an apply page which consists a simple form, but url should be as mentioned above.

I am trying to achieve it by using add_rewrite_rule(), but after trying too much, it is still redirecting me on the below url:

http://example.com/apply

Any help would be appreciated. Thanks in advance.

2 Answers
2

I assume you have a custom taxonomy for your CPT, so your CPT should be ‘job’ and your custom taxonomy can then be ‘jobs’ and then you’d have custom terms within that taxonomy for each job type. The Posts then would consist of the individual job with any associated relevant data (rate of pay, hours, etc).

If that is your setup – and how I would do it – then if you DON’T want the CPT or Taxonomy base in the URL, you do have to do a re-write (see this page for some more helpful advice).

Remove Custom Taxonomy Base

I think the problem you’re having is that you’re using a Page (Apply) to hold your form and related job data – which is why your re-write isn’t working.

Try changing to using a Template that is applied to all posts within the CPT, and put your form (either embedded or with a PHP call to the form) on your Template, using it to also pull in any custom metadata through a loop of your CPT and taxonomy.

Leave a Reply

Your email address will not be published. Required fields are marked *