Twenty Eleven: use a filter to modify the output of wp_title(). Props obenland, see #23774.

git-svn-id: http://core.svn.wordpress.org/trunk@23718 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Lance Willett 2013-03-15 18:15:58 +00:00
parent 87f4924dc9
commit c6720facd9
2 changed files with 32 additions and 21 deletions

View File

@ -614,3 +614,34 @@ function twentyeleven_body_classes( $classes ) {
}
add_filter( 'body_class', 'twentyeleven_body_classes' );
/**
* Creates a nicely formatted and more specific title element text
* for output in head of document, based on current view.
*
* @since Twenty Eleven 1.6
*
* @param string $title Default title text for current view.
* @param string $sep Optional separator.
* @return string Filtered title.
*/
function twentyeleven_wp_title( $title, $sep ) {
global $paged, $page;
if ( is_feed() )
return $title;
// Add the site name.
$title .= get_bloginfo( 'name' );
// Add the site description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
$title = "$title $sep $site_description";
// Add a page number if necessary.
if ( $paged >= 2 || $page >= 2 )
$title = "$title $sep " . sprintf( __( 'Page %s', 'twentyeleven' ), max( $paged, $page ) );
return $title;
}
add_filter( 'wp_title', 'twentyeleven_wp_title', 10, 2 );

View File

@ -24,27 +24,7 @@
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<meta name="viewport" content="width=device-width" />
<title><?php
/*
* Print the <title> tag based on what is being viewed.
*/
global $page, $paged;
wp_title( '|', true, 'right' );
// Add the blog name.
bloginfo( 'name' );
// Add the blog description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
echo " | $site_description";
// Add a page number if necessary:
if ( $paged >= 2 || $page >= 2 )
echo ' | ' . sprintf( __( 'Page %s', 'twentyeleven' ), max( $paged, $page ) );
?></title>
<title><?php wp_title( '|', true, 'right' ); ?></title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />