[wp-hackers] Custom post type conditionals

Simon Blackbourn piemanek at gmail.com
Sun May 16 19:21:29 UTC 2010

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.


More information about the wp-hackers mailing list