Codex

Function Reference/single cat title

Contents

Description

Displays or returns the page title if a category or tag archive is queried. Therefore, the function can be used only outside the loop.

Usage

 <?php single_cat_title$prefix$display ); ?> 

Default Usage

<?php single_cat_title( $prefix = '', $display = true ); ?>

Parameters

$prefix
(string) (optional) Text to output before the title.
Default: None
$display
(boolean) (optional) Should the page title be displayed (true) or returned for use in PHP (false).
Default: true

Return Values

(string/void) 
Page title if a category or tag archive is queried and the $display argument is set to false.

Examples

This example displays the text "Currently browsing " followed by the category title.

<p><?php single_cat_title('Currently browsing '); ?>.</p>
Currently browsing WordPress.


This example assigns the current category title to the variable $current_category for use in PHP.

<?php $current_category = single_cat_title("", false); ?>

Notes

Change Log

Since: Version 0.71

Source File

single_cat_title() is located in wp-includes/general-template.php.

Related

Categories: the_category(), the_category_rss(), single_cat_title(), category_description(), wp_dropdown_categories(), wp_list_categories(), get_the_category(), get_the_category_by_ID(), get_category_by_slug(), get_the_category_list(), get_category_parents(), get_category_link(), is_category(), in_category()

See also index of Function Reference and index of Template Tags.