Advertisements

is_single

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

Advertisements

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: