WordPress at Your Fingertips

is_single() WP 1.5.0

Checks whether the post page of any post type except attachment and page is displayed. Conditional tag.

Works for any post type, except attachments and pages.

You can limit the check to a specific post in the first parameter $post.

If you want to check whether a post of any type, including attachment and page, is displayed in the one check, use is_singular().

You can specify a check for posts of a specific type in is_singular( $post_type ).

1 time — 0.00003 sec (very fast) | 50000 times — 0.02 sec (speed of light)

No Hooks.


true|false. Whether the query is for an existing single post.


if( is_single( $post ) ){
	// ... 
Post ID, title, slug, or array of such.
Default: ''


#1 Various usage examples

// When any single Post page is being displayed.

// When Post 17 (ID) is being displayed.

// 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.

// 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 in version 2.5.

#2 Enqueue a CSS stylesheet for any single Post page

if( is_single() ){
	wp_enqueue_style( 'handle', 'path/to/cssfile.css' );

#3 A note about the Cyrillic and name (slug)

If your website does not change the Cyrillic to the Latin alphabet - plugin Сry to Lat (or similar) is not installed, when a post is created its name changes and Cyrillic transforms to special symbols (ex: contacts will be changed to %d0%ba%d0%be%d0%bd%d1%82%d0%b0%d0%ba%d1%82%d1%8b), so when checking you need to take this into account. I.e. if the name (post_name) is checked instead of the title, do so:

is_single('моя-страница'); // wrong

is_single( sanitize_title('моя-страница') ); // correct



Since 1.5.0 Introduced.

Code of is_single() WP 5.8.1

function is_single( $post = '' ) {
	global $wp_query;

	if ( ! isset( $wp_query ) ) {
		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
		return false;

	return $wp_query->is_single( $post );

Conditional tags (page type and request)

Conditional tags (all)


Main Functions

vladlu 100vlad.lu
Editors: Kama 101
No comments
    Log In