single_cat_title()WP 0.71

Display or retrieve page title for category archive.

Useful for category template files for displaying the category page title. The prefix does not automatically place a space between the prefix, so if there should be a space, the parameter value will need to have it at the end.

No Hooks.


String|null. Title when retrieving.


single_cat_title( $prefix, $display );
What to display before the title.
Default: ''
Whether to display or retrieve title.
Default: true



#1 Display the category or tag name on the archive page

This example will display the text "You are browsing: WordPress", where WordPress is the name of the current category:

<p><?php single_cat_title( 'You are browsing: ' ); ?>.</p>

#2 Write the name of the category in a variable

An example of how you can write a category name to the variable $current_cat_name, i.e. not display it on the screen (set the second parameter to 0).

$current_cat_name = single_cat_title( '', 0 );

echo $current_cat_name;


Since 0.71 Introduced.

single_cat_title() code WP 6.1.1

function single_cat_title( $prefix = '', $display = true ) {
	return single_term_title( $prefix, $display );