Blank space at beginning of tag?

The HTML output of all my WordPress pages has a blank space at the beginning of my <title> tag. You can see the effect here.

My header template contains this:

<title><?php wp_title(''); ?></title>

And roduces this:

<title> FAQ</title>

Any ideas on why this is happening?

1 Answer
1

It looks like your site’s title is empty. Fill it out or try for example:

add_filter( 'wp_title', function( $title )
{
    return trim( $title );
} );

to remove the blank space in front.

For your setup, the following part of wp_title() is responsible for the blank space:

$title = $prefix . implode( " $sep ", $title_array );

So when you’re on a single page, like FAQ, this will give you:

$title=" " . implode( " ", array( 'FAQ' ) );

or

$title=" FAQ";

Leave a Comment