Title: the_category_head
Published: April 25, 2014
Last modified: May 20, 2026

---

# the_category_head( string $before = '', string $after = '' )

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/the_category_head/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/functions/the_category_head/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/functions/the_category_head/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/the_category_head/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/the_category_head/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/the_category_head/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/the_category_head/?output_format=md#wp--skip-link--target)

This function has been deprecated since 0.71. Use [get_the_category_by_ID()](https://developer.wordpress.org/reference/functions/get_the_category_by_id/)
instead.

Prints a category with optional text before and after.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/the_category_head/?output_format=md#description)󠁿

### 󠀁[See also](https://developer.wordpress.org/reference/functions/the_category_head/?output_format=md#see-also)󠁿

 * [get_the_category_by_ID()](https://developer.wordpress.org/reference/functions/get_the_category_by_id/)

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/the_category_head/?output_format=md#parameters)󠁿

 `$before`stringoptional

Text to display before the category.

Default:`''`

`$after`stringoptional

Text to display after the category.

Default:`''`

## 󠀁[Source](https://developer.wordpress.org/reference/functions/the_category_head/?output_format=md#source)󠁿

    ```php
    function the_category_head( $before = '', $after = '' ) {
    	global $currentcat, $previouscat;

    	_deprecated_function( __FUNCTION__, '0.71', 'get_the_category_by_ID()' );

    	// Grab the first cat in the list.
    	$categories = get_the_category();
    	$currentcat = $categories[0]->category_id;
    	if ( $currentcat != $previouscat ) {
    		echo $before;
    		echo get_the_category_by_ID($currentcat);
    		echo $after;
    		$previouscat = $currentcat;
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/deprecated.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/deprecated.php#L107)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/deprecated.php#L107-L121)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/the_category_head/?output_format=md#related)󠁿

| Uses | Description | 
| [get_the_category()](https://developer.wordpress.org/reference/functions/get_the_category/)`wp-includes/category-template.php` |

Retrieves post categories.

  | 
| [get_the_category_by_ID()](https://developer.wordpress.org/reference/functions/get_the_category_by_id/)`wp-includes/category-template.php` |

Retrieves category name based on category ID.

  | 
| [_deprecated_function()](https://developer.wordpress.org/reference/functions/_deprecated_function/)`wp-includes/functions.php` |

Marks a function as deprecated and inform when it has been used.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/the_category_head/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/the_category_head/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/the_category_head/?output_format=md#changelog)󠁿

| Version | Description | 
| [0.71](https://developer.wordpress.org/reference/since/0.71/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_category_head%2F)
before being able to contribute a note or feedback.