[wp-hackers] custom post types and child pages

Steve Taylor steve at sltaylor.co.uk
Sat Apr 30 19:13:46 UTC 2011


Hi,

I've got a couple of questions about Custom Post Types which have come
up in the client project I'm working on. For now I'm suggesting they
just re-arrange the IA to avoid these issues, because I'm not sure
what they're after is possible. However, I'm curious whether anyone
thinks there are possibilities worth exploring.

They're both to do with child pages, one relating to CPT archives and
one relating to CPT single post views.

CPT ARCHIVES

Say I have "projects" as a CPT. The archive page is defined as living here:

/research/projects/

Now, this is also an actual WP page, which I use to manage the intro
to the archive list etc. The URL for a project will of course be:

/research/projects/project-x/

But what if they have some other information about projects and they
want a standard WP page here:

/research/projects/info/

This gives a 404 - presumably because the rewrite rules signal that
we're looking for a project and there's no project with the slug
"info".

For now I've advised that they make anything planned as a child page
of /research/projects/ into a sibling page - not too much of a
sacrifice, and very easy. However, I wonder if there's a way to step
into the rewriting process and say, "If there's no CPTs found under a
CPT archive URL, look for child pages of the page that has the same
URL as the CPT archive"? If anyone's achieved this, do let me know.

CPT SINGLE POST VIEWS

The other issue is that the ideal situation for this project is to
have child pages of CPTs. So if there's a project at this URL:

/research/projects/project-x/

As well as the main page, there might be an extra page for this project:

/research/projects/project-x/extra/

Or more... The whole idea doesn't make sense to me in WP terms - that
child couldn't be a page with a CPT as a parent.

I've tried making the CPT hierarchical, but it doesn't seem to make
sense to have a project as a child of a project for what I'm talking
about above. Besides, the child page throws a 404 :-\

Anyway, anyone wrestled with this stuff before?

cheers,

Steve Taylor


More information about the wp-hackers mailing list