the_title

The timeline below displays how wordpress function the_title has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.3

/**
 * Displays or retrieves the current post title with optional markup.
 *
 * @since 0.71
 *
 * @param string $before  Optional. Markup to prepend to the title. Default empty.
 * @param string $after   Optional. Markup to append to the title. Default empty.
 * @param bool   $display Optional. Whether to echo or return the title. Default true for echo.
 * @return void|string Void if `$display` argument is true or the title is empty,
 *                     current post title if `$display` is false.
 */
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;
    }
}

WordPress Version: 6.2

/**
 * Displays or retrieves the current post title with optional markup.
 *
 * @since 0.71
 *
 * @param string $before  Optional. Markup to prepend to the title. Default empty.
 * @param string $after   Optional. Markup to append to the title. Default empty.
 * @param bool   $display Optional. Whether to echo or return the title. Default true for echo.
 * @return void|string Void if `$display` argument is true, current post title if `$display` is false.
 */
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;
    }
}

WordPress Version: 6.1

/**
 * Displays or retrieves the current post title with optional markup.
 *
 * @since 0.71
 *
 * @param string $before Optional. Markup to prepend to the title. Default empty.
 * @param string $after  Optional. Markup to append to the title. Default empty.
 * @param bool   $echo   Optional. Whether to echo or return the title. Default true for echo.
 * @return void|string Void if `$echo` argument is true, current post title if `$echo` is false.
 */
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;
    }
}

WordPress Version: 5.4

/**
 * Display or retrieve the current post title with optional markup.
 *
 * @since 0.71
 *
 * @param string $before Optional. Markup to prepend to the title. Default empty.
 * @param string $after  Optional. Markup to append to the title. Default empty.
 * @param bool   $echo   Optional. Whether to echo or return the title. Default true for echo.
 * @return void|string Void if `$echo` argument is true, current post title if `$echo` is false.
 */
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;
    }
}

WordPress Version: 4.7

/**
 * Display or retrieve the current post title with optional markup.
 *
 * @since 0.71
 *
 * @param string $before Optional. Markup to prepend to the title. Default empty.
 * @param string $after  Optional. Markup to append to the title. Default empty.
 * @param bool   $echo   Optional. Whether to echo or return the title. Default true for echo.
 * @return string|void Current post title if $echo is false.
 */
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;
    }
}

WordPress Version: 4.3

/**
 * Display or retrieve the current post title with optional content.
 *
 * @since 0.71
 *
 * @param string $before Optional. Content to prepend to the title.
 * @param string $after  Optional. Content to append to the title.
 * @param bool   $echo   Optional, default to true.Whether to display or return.
 * @return string|void String if $echo parameter is false.
 */
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;
    }
}

WordPress Version: 3.7

/**
 * Display or retrieve the current post title with optional content.
 *
 * @since 0.71
 *
 * @param string $before Optional. Content to prepend to the title.
 * @param string $after Optional. Content to append to the title.
 * @param bool $echo Optional, default to true.Whether to display or return.
 * @return null|string Null on no title. String if $echo parameter is false.
 */
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;
    }
}