WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/the category head

Description

Displays the name of a category if it's different from the previous category. This tag must be used within The Loop.

Replace With

This tag was deprecated when multiple categories were added to WordPress, and there is no one-to-one correspondence with another tag.

To display the name of the category when on a category page, use:

<?php echo get_the_category_by_ID($cat); ?>

To display category name(s) on a single post page, this code (which would need to run in The Loop) provides an example:

<?php
foreach(get_the_category() as $category) {
    echo $category->cat_name . ' '; 
}
?>

Usage

 <?php the_category_head$before$after ); ?> 

Parameters

before 
(string) Text to output before the category. Defaults to '' (no text).
after 
(string) Text to output after the category. Defaults to '' (no text).

Example

Displays the text "Category: " followed by the name of the category.

<h2><?php the_category_head('Category: '); ?></h2>

Change Log

Related

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