[wp-hackers] Post/Page "Types"?
DD32
wordpress at dd32.id.au
Sat Nov 1 12:36:26 GMT 2008
On Sat, 01 Nov 2008 23:27:40 +1100, Mike Schinkel <mikeschinkel at gmail.com>
wrote:
>>> 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.
>
> Specifically? (thanks in advance. :)
Err... Not sure! :) It would depend on how you integrated the post_type in
with the rest of the code. It'd probably be possible to redirect it to use
the page template rather than something else.. *really* not sure on that
though.
>>> 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.
>
> I'd really rather handle it in PHP instead of a .htaccess file given that
> the latter can sometimes be difficult to get right; isn't there a place
> in
> the PHP code where I can pregmatch() for '#/company/([^/]+)/?#' set
> post_type?
Yeah, I was refering to using the WordPress Rewrite engine rather than
handling it with a htaccess
This old example plugin of mine:
http://dd32.id.au/files/wordpress/test-rewrite.php
shows how to use it for some custom rules.
>>> 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.
>
> Ugh. Is there are reason it is architected this way, or is it just
> because
> nobody has ever had a use-case that called this structure into question?
Well.. It makes sense in the way that WordPress is coded, If its a post,
then it makes sense to limit it to that particular post_type.. But if a
custom post_type has been given, that should logically over-ride that
check.. but it doesnt. (I never got around to filing a trac ticket as i
implemented what i wanted in a completely different way)
More information about the wp-hackers
mailing list