the_category_head

Prints a category with optional text before and after.

Description

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

Parameters (2)

0. $before — Optional. (string) => ''
Text to display before the category. Default empty.
1. $after — Optional. (string) => ''
Text to display after the category. Default empty.

Usage

  1. if ( !function_exists( 'the_category_head' ) ) { 
  2. require_once ABSPATH . WPINC . '/deprecated.php'; 
  3.  
  4. // Optional. Text to display before the category. Default empty. 
  5. $before = ''; 
  6.  
  7. // Optional. Text to display after the category. Default empty. 
  8. $after = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = the_category_head($before, $after); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/deprecated.php  
  1. function the_category_head( $before = '', $after = '' ) { 
  2. global $currentcat, $previouscat; 
  3.  
  4. _deprecated_function( __FUNCTION__, '0.71', 'get_the_category_by_ID()' ); 
  5.  
  6. // Grab the first cat in the list. 
  7. $categories = get_the_category(); 
  8. $currentcat = $categories[0]->category_id; 
  9. if ( $currentcat != $previouscat ) { 
  10. echo $before; 
  11. echo get_the_category_by_ID($currentcat); 
  12. echo $after; 
  13. $previouscat = $currentcat;