This text and video Quick Guide explains how to use is_singular()
, one of the more useful WordPress template tags. We also explain the difference between the is_singular()
conditional tag, and the two other related ones: is_page()
and is_single()
.
is_singular()
: One of WordPress’s Conditional Template Tags
WordPress’s conditional tags are little functions that tell you something about the WordPress content being displayed on a page.
For example, is_archive()
is another WordPress conditional tag, and it tells you if the content being displayed is a post archive: a list of posts from any WordPress post type, such as the front page of a blog section.
Our full article on WordPress conditional tags can help illuminate the concept, which is key to understanding how is_singular()
itself works and what it’s useful for:
How to Use WordPress Conditional Tags
Understanding the Difference Between is_single()
, is_singular()
, and is_page()
To understand the WordPress conditional tag is_singular()
, it’s useful to understand two related tags: is_page()
and is_single()
.
All three tags relate to the condition where only one WordPress post is being displayed. Within that constraint:
is_page()
will be true only if the piece of content being displayed is a single post of type Page.is_single()
is the confusing one. It will be true if the piece of content being displayed is a single post of any post type other than Page or Attachment.is_singular()
will be true no matter which the post type of the single piece of content being displayed.
So the three template tags work like this:
- If the single post is of type Page, then
is_page()
istrue
,is_single()
isfalse
, andis_singular()
istrue
. - If the single post is of type Post, then
is_page()
isfalse
,is_single()
istrue
, andis_singular()
istrue
. - If the single post is of any other post type (a custom post type), then
is_page()
isfalse
,is_single()
istrue
, andis_singular()
istrue
.
So, if either is_page()
or is_single()
conditional tags are true, is_singular
will always be true.
But if you’re going to display more than one of any post type (including Post and Page), then all of the above conditional tags will be false
.
Seeing it in Action: is_single()
PHP authoring, with is_singular()
Using is_singular()
: Make Something Disappear on Single-Entry HTML Pages
To use the conditional tag is_singular
to make something appear when your theme is showing single page or post:
- First, find the part of the theme file, say
footer.php
that you want to control this way. This should be 1-100 lines of HTML and PHP code. - Then, mindful of whether you’ve got PHP tags open or not, add the following line before the content you want to only show when
is_singular
is true:<?php if ( is_singular() ): ?>
- Then, add the following line after the content you want to only show in certain conditions:
<?php endif; ?>
.
Test it. It should work.
Quick note: saying not
in PHP is usually done with a !
(often pronounced “bang” or “exclamation point”). So to show this in the opposite conditions, you’d change the code you added in step #2 to: <?php if ( !is_singular() ): ?>
. The easiest way I know to read that is “if is not singular”, although it does literally read more like “if not is singular.” But that’s a little too Yoda-y for my brain.
Example Code Block for is_singular()
in WordPress
Finally, if you’re helped by a big single code-block, here’s an example use of is_singular()
in PHP:
<?php if ( is_singular() ): ?>
<h2>Popular posts</h2>
<ul>
<li><a href="https://wpshout.com/courses/wordpress-development/">Course: Learn WordPress Development</a></li>
<li><a href="https://wpshout.com/complete-guide-wordpress-security/">Complete Guide to WordPress Security</a></li>
<li><a href="https://wpshout.com/wordpress-page-builder-review/">WordPress Page Builders, Reviewed</a></li>
</ul>
<?php endif; ?>
Serious About Learning WordPress Development?
Thanks for learning how is_singular()
works in WordPress!
Master Modern WordPress Development 🏆
Get ‘Modern WordPress Fast Track’ today
Become a WordPress Developer Who Can Build Anything
Learn to build high-value block themes and plugins with AI and automation in a focused 10-week course. By the end, you’ll master block themes and plugins, leverage AI assistance, implement automated testing, optimize for scale, and confidently deploy professional WordPress solutions.
Presale is currently open with 40% OFF until May 23rd, 2025. 🚀
Course starts June 1st.
We have prepared special bonuses for everyone who enrolls during this period! 🎁