Definition:
function is_single( $post = '' ) {}
Is the query for a single post?
Works for any post type, except attachments and pages
Parameters
- mixed $post: Post ID, title, slug, or array of such.
Source code
function is_single( $post = '' ) {
if ( !$this->is_single )
return false;
if ( empty($post) )
return true;
$post_obj = $this->get_queried_object();
$post = (array) $post;
if ( in_array( $post_obj->ID, $post ) )
return true;
elseif ( in_array( $post_obj->post_title, $post ) )
return true;
elseif ( in_array( $post_obj->post_name, $post ) )
return true;
return false;
}
2183

February 12, 2011 


No comments yet... Be the first to leave a reply!