Function to return single post / page ID
|Reported by:||Viper007Bond||Owned by:||anonymous|
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.