4

I have the following structure:

  • /projects (archive of cpt projects with template archive-projects.php)
  • /projects/project-1 (single view of cpt with template single-projects.php)
  • /projects/downloads (this is a page)

When I try to open /projects/downloads I get an 404 error. Is there a way to set a page in the custom post type hierarchy?

2 Answers 2

3

This is possible, but it will require playing with the rewrite rules. Install my Rewrite analyzer, you will need it.

I answered a very similar question, but the main difference was that where you have /projects/ as a "clean" custom post type archive, the other user had it as a page, which is much easier.

If you want to create subpages of /projects/ you will have to create a page with the slug projects. Then you have two options: the easy one is to use a page template for this /projects/ page that just queries for your custom post type, like we used to do before WP 3.1 arrived with native support for custom post type archives. The other option is to filter the verbose page rules and throw out everything related to the /projects/ page, so that only the /projects/ rules for the custom post type archive remain.

3
  • Thanks a lot for your feedback! I tried the easy option and it did not work. I think it has to do with the WPML plugin. /projects/ (cpt archive project) --> Works /projects/project-1 (cpt single project) --> Works /projects/downloads (page) --> Works /projects/clients (page) --> Works /en/projects/ (cpt archive project) --> Works /en/projects/project-1 (cpt single project) --> Works /en/projects/downloads (page) --> 404 Error /en/projects/clients (page) --> 404 Error Could this be solved with verbose page rules?
    – Aldo
    Commented May 26, 2011 at 20:11
  • @Aldo: Hmm, this could indeed be the WPML plugin, I don't know how it changes the URL parsing. Have you tried my plugin to see what your rules look like?
    – Jan Fabry
    Commented May 26, 2011 at 20:21
  • Yes, I did, but I dont knwo how to interpret the results... This is what I get whith the path who does not work: (.+?)/?$ --> category_name: en/projects/downloads
    – Aldo
    Commented May 26, 2011 at 20:45
1

here is an idea, create a custom post type say downloads with rewrite slug projects/downloads and then each download as a new post of downloads custom post type.

4
  • thanks! this could work.the problem is, depending on how many child pages there are, the corresponding cpt have to be created. i'm looking for a more dynamic solution.
    – Aldo
    Commented May 26, 2011 at 6:56
  • i'm missing the point, you can have as many as you want.
    – Bainternet
    Commented May 26, 2011 at 10:15
  • If you want to have /projects/downloads/, /projects/testimonials/ /projects/something-else/, then you would need to write a custom post type for all of them, no?
    – Jan Fabry
    Commented May 26, 2011 at 15:55
  • @Jan: yep, that's the main idea.
    – Bainternet
    Commented May 26, 2011 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.