0

I'm working on a wordpress install that functions more like a web application than a traditional website, and I'm trying to get my head around the add_rewrite_rule system.

Currently I have three custom post types called "Programmes", "Surveys", and "Candidates". Each programme has multiple surveys, and each survey has multiple candidates. I currently have a URL structure like the following:

Programme Overview: /programmes/programme-1/
Survey Overview:    /programmes/programme-1/?survey=survey-1&view=overview
Survey Candidates:  /programmes/programme-1/?survey=survey-1&view=candidates&page=1
Candidate Overview: /programmes/programme-1/?survey=survey-1&view=candidate-1

This works okay but is obviously a bit messy, especially when I also start adding extra query strings like pagination. I currently just check for the post_id and query strings to load the correct template/content.

Ideally I want to have a URL structure that looks more like this:

Programme Overview: /programme-1/
Survey Overview:    /programme-1/survey-1
Survey Candidates:  /programme-1/survey-1/candidates/?page=1
Candidate Overview: /programme-1/survey-1/candidate-1

Something to note is that one survey can be attached to multiple programmes, and the user is allowed access to it depending on the combination of the two, which is handled by some logic within the templates. Example:

/programme-1/survey-1
/programme-1/survey-2
/programme-2/survey-1 // same survey as /programme-1/survey-1
/programme-2/survey-2 // same survey as /programme-1/survey-2

I'm really not sure where to start with the rewrite rules, I've had a look on the docs and through some of the other posts on here, but I'm still at a loss, so if there is anyone out there who may be able to give me a little guidence I'd really appreciate it!

1
  • Check my updated answer on this post which looks a lot like your question.
    – Jos Faber
    Jul 10 at 6:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.