W3cubDocs

/WordPress

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

Display or retrieve the current post title with optional markup.

Description

Parameters

$before

(string) (Optional) Markup to prepend to the title.

Default value: ''

$after

(string) (Optional) Markup to append to the title.

Default value: ''

$echo

(bool) (Optional) Whether to echo or return the title. Default true for echo.

Default value: true

Return

(string|void) Current post title if $echo is false.

Source

File: wp-includes/post-template.php

function the_title( $before = '', $after = '', $echo = true ) {
	$title = get_the_title();

	if ( strlen( $title ) == 0 ) {
		return;
	}

	$title = $before . $title . $after;

	if ( $echo ) {
		echo $title;
	} else {
		return $title;
	}
}

Changelog

Version Description
0.71 Introduced.

© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/the_title