[wp-trac] [WordPress Trac] #6345: Function to return single post / page ID

WordPress Trac wp-trac at lists.automattic.com
Sat Mar 22 02:25:29 GMT 2008

#6345: Function to return single post / page ID
 Reporter:  Viper007Bond  |       Owner:  anonymous  
     Type:  enhancement   |      Status:  new        
 Priority:  normal        |   Milestone:  2.7        
Component:  General       |     Version:  2.5        
 Severity:  normal        |    Keywords:  needs-patch
 Proposal for a new function for use outside of The Loop:

 If you're on a single post or page (i.e. `is_single()` or `is_page()` is
 `TRUE`), this function would return the ID of that post or page, otherwise
 it'd return `NULL` or whatever.

 Now before you suggest it, `global $post; echo $post-ID;` is unreliable
 because it can be thrown off by other Loops such as the "Recent Posts"
 sidebar widget.

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

More information about the wp-trac mailing list