WordPress single_cat_title() Function

Beginner
4 min read
Updated: Nov 2026
3 examples
Archive title

Definition

In WordPress, single_cat_title() shows the name of the current category on a category archive page, such as "News" or "Tutorials".

It works on archive pages only. On other pages it prints nothing. The category tag is_category() is a good check to use first.

Syntax

Use it in category.php or archive.php.

WordPress
<?php
single_cat_title();
CallWhat it does
single_cat_title()Prints the category name.
single_cat_title( 'Category: ' )Prints the name with a prefix.
single_cat_title( '', false )Returns the name instead of printing.

Related functions: single_tag_title() for tags and single_term_title() for any term.

Full declaration
WordPress
single_cat_title( string $prefix = '', bool $display = true ): string|void

Parameters

ParameterDescription
$prefixstring. Text to print before the name. Default is empty.
$displaybool. true (default) prints the name. false returns it.

Return Value

Return ValueDescription
voidWhen $display is true, the name is printed.
stringWhen $display is false, the name is returned (without the prefix).

WordPress Examples

Three short theme examples. Each one shows the code and what it prints.

Example 1 — Category page heading

Print the name in an h1.

WordPress
<h1><?php single_cat_title(); ?></h1>

How It Works

  1. The visitor is on the "News" category archive.
  2. The function prints its name.
  3. The name goes inside the h1.

Example 2 — Add a prefix

Print "Category: News".

WordPress
<h1><?php single_cat_title( 'Category: ' ); ?></h1>

How It Works

  1. The first argument is printed before the name.
  2. Add the space at the end of the prefix.
  3. The heading is now easier to scan.

Example 3 — Return the name

Use the name in a message.

WordPress
<?php
if ( is_category() ) {
  $cat = single_cat_title( '', false );
  echo 'Posts filed under ' . esc_html( $cat );
}

How It Works

  1. is_category() makes sure we are on a category archive.
  2. false returns the name.
  3. We build the message and escape the name.

Frequently Asked Questions

It prints or returns the name of the current category on a category archive page.
Nothing. It only works on category archives. Use get_the_category() for the categories of a post.
Pass false as the second argument: single_cat_title( '', false ).
Use single_tag_title() for tags and single_term_title() for any term archive.

Next: single_month_title()

Print or return the month and year of the current monthly archive.

single_month_title() 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.

6 people found this page helpful