Quantcast

custom post types and child pages

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

custom post types and child pages

Steve Taylor-15
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
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: custom post types and child pages

Jesus Lizama
I'm having a similar problem. Any help would be appreciated!

Also, has anyone had issues with next_posts_link() and previous_posts_link()
when using custom taxonomies and permalink structures? I can't get the
paging to work on custom taxonomy template files. :(


On Sat, Apr 30, 2011 at 12:13 PM, Steve Taylor <[hidden email]> wrote:

> 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
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>



--
Jesus Lizama
Developer/Designer
Spifffy.com | ConquerLA.com
Cell: (323)336-2953
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: custom post types and child pages

John Blackbourn
In reply to this post by Steve Taylor-15
On 30 April 2011 20:13, Steve Taylor <[hidden email]> wrote:

> 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.

I have the same situation. What I done was to add a filter to the
rewrite rules array and add a couple of rewrite rules that match the
page slugs [1]. It doesn't automatically work for all pages, but as
it's a project for a client  know there will only ever be those two
child pages. If we end up adding other pages then I'll just add their
slugs to the array and regenerate the rewrite rules.

It would be neat to come up with an automated solution. It could
probably be done fairly easily (I'm thinking along the lines of
fetching all child pages of page 'foo' and adding them to the rewrite
rules array and flushing the rules when new pages are added).

> 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 :-\

For some reason hierarchical CPTs don't get hierarchical URLs. This
has always been the case and I'm not sure why.

At first thought allowing inter-mixing of CPTs and pages doesn't make
a whole lot of sense, but I can see a need for it. I remember back in
the old days (when rewrite rules were in .htaccess) we had a separate
rewrite rule for every page on the site. I'm not for a moment
suggesting we go back to that by defauly, but it would offer a
solution for those who needed it.

[1] http://pastebin.com/rEu1BEkr

John
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: custom post types and child pages

Joel Fisher

See if this solves your issues.

http://wordpress.org/extend/plugins/simple-custom-post-type-archives/

Sent from my iPhone

On Apr 30, 2011, at 3:46 PM, John Blackbourn <[hidden email]> wrote:

> On 30 April 2011 20:13, Steve Taylor <[hidden email]> wrote:
>> 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.
>
> I have the same situation. What I done was to add a filter to the
> rewrite rules array and add a couple of rewrite rules that match the
> page slugs [1]. It doesn't automatically work for all pages, but as
> it's a project for a client  know there will only ever be those two
> child pages. If we end up adding other pages then I'll just add their
> slugs to the array and regenerate the rewrite rules.
>
> It would be neat to come up with an automated solution. It could
> probably be done fairly easily (I'm thinking along the lines of
> fetching all child pages of page 'foo' and adding them to the rewrite
> rules array and flushing the rules when new pages are added).
>
>> 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 :-\
>
> For some reason hierarchical CPTs don't get hierarchical URLs. This
> has always been the case and I'm not sure why.
>
> At first thought allowing inter-mixing of CPTs and pages doesn't make
> a whole lot of sense, but I can see a need for it. I remember back in
> the old days (when rewrite rules were in .htaccess) we had a separate
> rewrite rule for every page on the site. I'm not for a moment
> suggesting we go back to that by defauly, but it would offer a
> solution for those who needed it.
>
> [1] http://pastebin.com/rEu1BEkr
>
> John
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: custom post types and child pages

Dion Hulse (dd32)
In reply to this post by John Blackbourn
On 1 May 2011 05:46, John Blackbourn <[hidden email]> wrote:

> On 30 April 2011 20:13, Steve Taylor <[hidden email]> wrote:
> > 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 :-\
>
> For some reason hierarchical CPTs don't get hierarchical URLs. This
> has always been the case and I'm not sure why.
>

for CPT's, It's always been the case that they do get hierarchical url's *if
registered as a hierarchical type* AND the rewrite rules have been flushed
since you registered it like that. Often people will register it as
non-hierarchical, flush the rules, see everything is good, and THEN set it
to hierarchical and wonder why the url's are 404ing (they haven't flushed
their rules since setting the hierarchical flag);.
For Custom Taxonomies, Initially hierarchical taxonomies didn't support
hierarchical url's, Thats now supported, Pass rewrite =>
array('hierarchical' => true); to the args when you register the taxonomy.


On 1 May 2011 07:11, Joel Fisher <[hidden email]> wrote:

>
> See if this solves your issues.
>
> http://wordpress.org/extend/plugins/simple-custom-post-type-archives/
>

For that, I'd suggest looking into the 'has_archive' register_post_type
argument before attempting that plugin, It seems to duplicate what's in
WordPress 3.1+
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Loading...