the_title( string $before = '', string $after = '', bool $display = true ): void|string
- Since
- 0.71
- Source
wp-includes/post-template.php:43
Displays or retrieves the current post title with optional markup.
Parameters
$beforestringoptional- Markup to prepend to the title. Default empty.Default:
'' $afterstringoptional- Markup to append to the title. Default empty.Default:
'' $displaybooloptional- Whether to echo or return the title. Default true for echo.Default:
true
Return
void|string- Void if
$displayargument is true or the title is empty, current post title if$displayis false.
Uses · 1
- get_the_title()Retrieves the post title.
Used by · 3
- Twenty_Eleven_Ephemera_Widget::widget()Outputs the HTML for this widget.
- Twenty_Fourteen_Ephemera_Widget::widget()Outputs the HTML for this widget.
- twenty_twenty_one_continue_reading_text()Creates continue reading text.
Source
function the_title( $before = '', $after = '', $display = true ) { $title = get_the_title(); if ( strlen( $title ) === 0 ) { return; } $title = $before . $title . $after; if ( $display ) { echo $title; } else { return $title; }}History
Introduced in 0.71. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/post-template.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.