the_title

Display or retrieve the current post title with optional markup.

Description

(string|void) the_title( (string) $before = '', (string) $after = '', (bool) $echo = true ); 

Returns (string|void)

Current post title if $echo is false.

Parameters (3)

0. $before — Optional. (string) => ''
Markup to prepend to the title. Default empty.
1. $after — Optional. (string) => ''
Markup to append to the title. Default empty.
2. $echo — Optional. (bool) => true
Whether to echo or return the title. Default true for echo.

Usage

  1. if ( !function_exists( 'the_title' ) ) { 
  2. require_once ABSPATH . WPINC . '/post-template.php'; 
  3.  
  4. // Optional. Markup to prepend to the title. Default empty. 
  5. $before = ''; 
  6.  
  7. // Optional. Markup to append to the title. Default empty. 
  8. $after = ''; 
  9.  
  10. // Optional. Whether to echo or return the title. Default true for echo. 
  11. $echo = true; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = the_title($before, $after, $echo); 
  15.  

Defined (1)

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

/wp-includes/post-template.php  
  1. function the_title( $before = '', $after = '', $echo = true ) { 
  2. $title = get_the_title(); 
  3.  
  4. if ( strlen($title) == 0 ) 
  5. return; 
  6.  
  7. $title = $before . $title . $after; 
  8.  
  9. if ( $echo ) 
  10. echo $title; 
  11. else 
  12. return $title;