[wp-hackers] Post/Page "Types"?

DD32 wordpress at dd32.id.au
Sat Nov 1 12:09:05 GMT 2008


On Sat, 01 Nov 2008 22:46:37 +1100, Mike Schinkel <mikeschinkel at gmail.com>  
wrote:

> That said, how hard-coded is the "post" vs. "page" logic in the core?   
> For
> example I remember fighting the code in /wp-includes/template-loader.php
> because of the level to which it is hard-coded to assumptions. This would
> need to be changed, no?

There'll be a couple of hooks you can use to direct it to a different  
template than what it's trying to load, so no core mods should be required.

> And what about URL routing? I haven't looked at that so don't even know
> where to start (I'm assuming that custom post_types would have their own  
> URL
> template.)

You'd need to define you're own url's for sure.
adding a rewrite rule for '/company/([^/]+)/?' =>  
'index.php?post_type=company&post_name=$match[1]' would probably achieve  
it, Allthough i'm not too sure if the post_type can go via the URL.. So  
you might need to register it as 'index.php?company=$match[1]' and then  
hook in on one of the post_queries hooks to modify it.

Templates could be a bit messy.. I've never attempted it too much, The  
only time i've done it was with a page with a Custom template which was  
making a get_posts() call.

http://trac.wordpress.org/browser/trunk/wp-includes/query.php#L2067
is the only place i know that's a PITA, Due to the way that branch is  
setup, You cant use ?p=123 where 123 is a custom-type as it sets it to  
post in the end, Same goes for a few other query params.. I remember there  
was a way around it, but cant remember it.


More information about the wp-hackers mailing list