Tag Archives: seo
I wanted my homepage title to reveal my writing goals and interests. The importance of the title, to me, is obvious:
- It’s one of the first things people notice.
- It’s visible in the window chrome, the tabs, the bookmarks
- It’s something search engines pay attention to
WordPress settings allow you to set the blog title and description. With this modification, the description will be appended whenever a post title is not displayed, to avoid making it extremely long.
Edit the functions.php file of your template and append:
add_filter('wp_title', 'dv_wp_title', 100, 3);
$dv_append_subtitle = false;
function dv_wp_title($title)
{
global $dv_append_subtitle;
if($title === '')
$dv_append_subtitle = true;
return $title;
}
function dv_the_subtitle($sep = '—')
{
global $dv_append_subtitle;
if($dv_append_subtitle)
{
echo $sep ? $sep . ' ' : '';
bloginfo('description');
}
}
Then go to header.php and make your title tag look like this (notice that I added the dv_the_subtitle call)
And that’s it! If you want to customize the separator, which defaults to — pass it as an argument to dv_the_subtitle.
if ( comments_open() ) { ?>