[wp-trac] [WordPress Trac] #12588: Add function to check if current page is a custom post type

WordPress Trac wp-trac at lists.automattic.com
Sat May 8 21:25:27 UTC 2010


#12588: Add function to check if current page is a custom post type
----------------------------+-----------------------------------------------
 Reporter:  sirzooro        |        Owner:  nacin   
     Type:  enhancement     |       Status:  reopened
 Priority:  normal          |    Milestone:  3.0     
Component:  Administration  |      Version:  3.0     
 Severity:  normal          |   Resolution:          
 Keywords:  has-patch       |  
----------------------------+-----------------------------------------------

Comment(by scribu):

 Replying to [comment:17 sirzooro]:
 > > > One more thing: previous function version allowed to skip $types
 param, and uses all post types (returned by get_post_types()) as default.
 Please change is_post_of_type() to follow this.
 > >
 > > I disagree. It's meant to check agains specific post types; that's why
 it's called is_post_of_type() you know...
 >
 > I need this to do some things for all post types, e.g. print meta
 headers in <head>, which are stored as post meta data. The easiest way
 would be to just check if `is_post_of_type()` will return `true`. But this
 is not a problem - I can use `is_post_of_type( get_post_types() )`
 instead.

 You should be able to use is_single() instead. From the doc:

 {{{
  * This applies to other post types, attachments, pages, posts. Just means
 that
  * the current query has only a single object.
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/12588#comment:19>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list