[wp-hackers] Post/Page "Types"?
Mike Schinkel
mikeschinkel at gmail.com
Sat Nov 1 12:27:40 GMT 2008
>> 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. :)
>> 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?
>> 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?
BTW, I just found Flutter which, while not having the post_type
functionality it have some of the needed functionality:
http://freshout.us/goodies/fresh-post-for-wordpress-wordpress-cms/
Thanks again.
-Mike Schinkel
http://mikeschinkel.com
-----Original Message-----
From: wp-hackers-bounces at lists.automattic.com
[mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of DD32
Sent: Saturday, November 01, 2008 8:09 AM
To: wp-hackers at lists.automattic.com
Subject: Re: [wp-hackers] Post/Page "Types"?
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.
_______________________________________________
wp-hackers mailing list
wp-hackers at lists.automattic.com
http://lists.automattic.com/mailman/listinfo/wp-hackers
More information about the wp-hackers
mailing list