WordPress is_single() Function

Beginner
4 min read
Updated: Nov 2026
3 examples
Conditional tag

Definition

In WordPress, is_single() returns true when the visitor is viewing a single blog post (or a single custom post type item). It is false on Pages and attachments.

Call it with no argument to match any single post. Pass an ID, a title, or a slug to match one post.

Syntax

Use it as the test of an if statement.

WordPress
if ( is_single() ) {
  // code for the true path
} else {
  // code for the false path
}
CallWhat it does
is_single()True on any single post.
is_single( 'hello-world' )True on the post with the slug hello-world.
is_single( array( 17, 19 ) )True on the post with ID 17 or 19.

To include Pages and attachments too, use is_singular().

Full declaration
WordPress
is_single( int|string|int[]|string[] $post = '' ): bool

Parameters

ParameterDescription
$postOptional. A post ID, title, slug, or an array of them. Default is empty, which means any single post.

Return Value

Return ValueDescription
booltrue if the main query is for a single post, otherwise false.

Quick comparison:

Page typeis_single()is_singular()is_page()
Blog posttruetruefalse
Page (About)falsetruetrue
Attachmentfalsetruefalse
Custom post (book)truetruefalse

WordPress Examples

Three short theme examples. Each one shows what prints on the true path and the false path.

Example 1 — Any single post

Print a share note under every post.

WordPress
<?php if ( is_single() ) {
  echo '<p>Share this post with a friend.</p>';
} ?>

How It Works

  1. is_single() is true on a blog post.
  2. It is false on Pages.
  3. The note is printed only on posts.

Example 2 — One post by slug

Add a special box on one post.

WordPress
<?php if ( is_single( 'hello-world' ) ) {
  echo '<p>This is our first post!</p>';
} ?>

How It Works

  1. 'hello-world' is the post slug.
  2. Only that post returns true.
  3. Other posts skip the box.

Example 3 — Post, Page, or other

See how the three tags answer.

WordPress
<?php
if ( is_single() ) {
  echo 'single post';
} elseif ( is_page() ) {
  echo 'Page';
} elseif ( is_singular() ) {
  echo 'other single view';
} ?>

How It Works

  1. is_single() catches posts first.
  2. is_page() catches Pages.
  3. is_singular() catches the rest, such as attachments.

Frequently Asked Questions

It returns true or false (a bool). Use it inside an if statement.
is_single() is for posts. is_singular() is true on any single view: posts, Pages, attachments, and custom post types.
Yes. A single custom post (for example a book) is true for is_single(). It is false for Pages.
Pages are not posts. Use is_page() for a Page, or is_singular() for both.
Conditional tags need the main query. Call them in template files or on hooks such as wp or template_redirect, not directly at the top of functions.php.

Next: is_singular()

Check if the current page is any single view: post, Page, attachment, or custom type.

is_singular() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

13 people found this page helpful