WordPress single_cat_title() Function

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

Definition

In WordPress, single_cat_title() gives you the name of the category on a category archive page. Use it for the page heading.

By default it prints the name. Set $display to false to return the name instead. It only works on archive pages.

Syntax

Call it on a category archive. Pass a prefix, or set display to false to get the name as a string.

WordPress
single_cat_title();
single_cat_title( 'Category: ' );
$name = single_cat_title( '', false );
CallWhat it does
single_cat_title()Prints the category name.
single_cat_title( 'Category: ' )Prints the prefix, then the name.
single_cat_title( '', false )Returns the name as a string. Nothing is printed.

Use it in category.php or archive.php. It does nothing on other pages.

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

Parameters

ParameterDescription
$prefixOptional. Text placed before the name when it is printed. Default is an empty string.
$displayOptional. true prints the name (default). false returns it.

Return Value

Return ValueDescription
stringThe category name. Returned only when $display is false.
voidNothing is returned when the name is printed, or when the page is not a category archive.

WordPress Examples

Three short theme examples. Each one has a sample output.

Example 1 — Print the title

Show the category name in a heading.

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

How It Works

  1. On a category archive the function prints the category name.
  2. Put it inside your own h1 tag.
  3. No echo is needed because it prints by itself.

Example 2 — Add a prefix

Print a small label before the name.

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

How It Works

  1. The first argument is the prefix.
  2. WordPress prints the prefix and then the name.
  3. Include the space inside the prefix text.

Example 3 — Return the name

Get the name as a string and escape it.

WordPress
<?php
$name = single_cat_title( '', false );
echo '<h1>Posts in ' . esc_html( $name ) . '</h1>';
?>

How It Works

  1. false tells the function to return the name.
  2. The name is saved in $name.
  3. esc_html() keeps the output safe.

Frequently Asked Questions

It prints the name of the current category on a category archive page. With $display set to false, it returns the name.
No. It only works on archive pages. On a single post, use get_the_category() or the_category().
Pass false as the second argument: single_cat_title( '', false ).
No. The prefix is added only when the name is printed.
single_cat_title() is meant for categories. single_term_title() works for categories, tags, and custom taxonomies.

Next: single_tag_title()

Print or return the title (name) of the current tag archive.

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

9 people found this page helpful