Warning: This function has been deprecated. Use get_the_category_by_ID() instead.

the_category_head() WordPress Function

The the_category_head() function is used to display the category heading for a post in a WordPress site. This function is used within the WordPress loop.

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

Prints a category with optional text before and after.


Description

Top ↑

See also


Top ↑

Parameters

$before

(string)(Optional) Text to display before the category.

Default value: ''

$after

(string)(Optional) Text to display after the category.

Default value: ''


Top ↑

Source

File: wp-includes/deprecated.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;
	}
}


Top ↑

Changelog

Changelog
VersionDescription
0.71Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More