[wp-hackers] Custom post type conditionals
Mike Schinkel
mikeschinkel at newclarity.net
Sun May 16 19:39:13 UTC 2010
Hi Simon:
Have you considered creating custom templates, i.e. "single-my_post_type.php?" (I know that might not be applicable to your use case, but if it is...)
OTOH, if your plugin adds a post type maybe your plugin should be the one to add the conditional? i.e.:
function is_my_post_type() {
return $wp_query->query_vars['post_type']=='my_post_type';
}
-Mike
On May 16, 2010, at 3:21 PM, Simon Blackbourn wrote:
> I have a site with several different custom post types and would like to
> test (outside of the loop) which post type is currently being queried.
>
> As far as I can see the only conditional available is "is_post_type", which
> simply tells you if a particular post type has been registered, and with a
> post ID passed in it tells you if that post is of that type.
>
> Is there any conditional that tells me if I'm on an archive page for a
> particular post type, or on a single page for a post type, without having to
> pass in a post ID (so it can be used outside of the loop, similar to
> is_archive and is_single)?
>
> At the moment I'm testing $wp_query->query_vars['post_type'] but a
> conditional would be much nicer.
>
> Cheers
> Simon
> _______________________________________________
> 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