[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
Thu Mar 11 20:30:22 UTC 2010


#12588: Add function to check if current page is a custom post type
----------------------------+-----------------------------------------------
 Reporter:  sirzooro        |       Owner:             
     Type:  defect (bug)    |      Status:  new        
 Priority:  normal          |   Milestone:  3.0        
Component:  Administration  |     Version:  3.0        
 Severity:  normal          |    Keywords:  needs-patch
----------------------------+-----------------------------------------------
 From #9674:

 There is one important piece missing, as Denis-de-Bernardy pointed
 earlier:

 >Following up on the previous remark... some kind of is_custom() function
 would be useful, and a means to bypass the WP query entirely in the
 workflow immediately after the query is parsed. else WP_Query may get
 loaded with junk. init_query_flags() for instance, probably also needs
 some reference to is_custom = false. after parse_query is done, $wp_query
 filters itself through do_action_ref_array(), and if it ends up with
 is_custom set to true at that stage, the actual WP query gets skipped
 entirely -- WP should then make the assumption that it has been set up
 already. I don't think we actually need anything in the template loader,
 since there is a hook in there already. But there definitely needs
 something over in the wp_query query class to go something like: please
 bail the WP query.

 I would like to see function with following declaration, in order to be
 able to check if current page belongs to given post type and/or give list
 of custom posts to test against:[[BR]]
 `function is_custom( $post_type = '', $post_id = '' )`

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


More information about the wp-trac mailing list