[wp-hackers] custom_post_type and custom taxonomy naming

Lox lox.dev at knc.nc
Sun Aug 22 05:49:19 UTC 2010


2010/8/22 Mike Schinkel <mikeschinkel at newclarity.net>

> For example, having a "product" taxonomy *could* give a list of posts at
> http://example.com/products/ and then each "product" post could display at
> http://example.com/products/%product%/
>
> What I am currently doing is setting "rewrite" to false for the taxonomy
> and creating a Page for the /products/ URL and using a shortcode to retrieve
> the posts I want displayed.  My shortcode accepts "post_type" and defaults
> to using WP_Query() to generate a full list of all posts of my post type but
> with additional arguments that allow me to specify what WP_Query() will get
> passed.  By default my shortcode looks for "page-%post_type%.php" in my
> theme's directory to display a single post so for a product it would look
> for "post-product.php.
>

This is EXACTLY what I end up doing execpt that it falls back to the
templates located in a template directory of my plugin (based on twenty
ten), so it doesn't need to have the tempates in the theme dir to work.

But I have just found a better way. Having a full page template for each
post type is a hassle to maintain, so I went using a trick that works like
get_template_part() execpt that it looks for the template fragment in my
plugin's template dir first. But those can be override by creating them in
the theme folder.


> That all works rather well but takes a bit too much fiddling for what I
> think is an would be a common use-case.  It would be nice if a URL for
> http://example.com/%post_type%/ would be automatically generated and if
> there is a taxonomy with the same name that the taxonomy would be
> automatically mirrored and that the /%post_type%/ URL would then be filtered
> by the posts that are associated with that taxonomy. JMTCW, as always.
>

+100 for that! This is missing me since the first day I tried custom
post-types.


-- 
Lox
lox.dev at knc.nc


More information about the wp-hackers mailing list