WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/is single

Contents

Description

This conditional tag checks if a single post of any post type except attachment and page post types is being displayed. If the $post parameter is specified, the function will additionally check if the query is for one of the posts specified. To check for all the post types, use the is_singular() function.

Usage

<?php is_single($post); ?>

Parameters

$post
(mixed) (optional) Post ID, Post Title or Post Slug
Default: None

Return Values

(boolean) 
True on success, false on failure.

Examples

is_single();
// When any single Post page is being displayed.

is_single('17');
// When Post 17 (ID) is being displayed.

is_single(17);
// When Post 17 (ID) is being displayed. Integer parameter also works
is_single('Irish Stew');
// When the Post with post_title of "Irish Stew" is being displayed.

is_single('beef-stew');
// When the Post with post_name (slug) of "beef-stew" is being displayed.

is_single(array(17,'beef-stew','Irish Stew'));
// Returns true when the single post being displayed is either post ID 17, or the post_name is "beef-stew", or the post_title is "Irish Stew".  Note: the array ability was added at Version 2.5.

Notes

Change Log

Since: 1.5.0

Source File

is_single() is located in wp-includes/query.php.

Related

See also index of Function Reference and index of Template Tags.