Twenty Ten: use a filter to modify the output of `wp_title()`. Props obenland, closes #23774.
git-svn-id: http://core.svn.wordpress.org/trunk@23719 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c6720facd9
commit
24e099bb3e
|
@ -514,3 +514,35 @@ function twentyten_posted_in() {
|
|||
);
|
||||
}
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Creates a nicely formatted and more specific title element text
|
||||
* for output in head of document, based on current view.
|
||||
*
|
||||
* @since Twenty Ten 1.6
|
||||
*
|
||||
* @param string $title Default title text for current view.
|
||||
* @param string $sep Optional separator.
|
||||
* @return string Filtered title.
|
||||
*/
|
||||
function twentyten_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', 'twentyten' ), max( $paged, $page ) );
|
||||
|
||||
return $title;
|
||||
}
|
||||
add_filter( 'wp_title', 'twentyten_wp_title', 10, 2 );
|
||||
|
|
|
@ -12,27 +12,7 @@
|
|||
<html <?php language_attributes(); ?>>
|
||||
<head>
|
||||
<meta charset="<?php bloginfo( 'charset' ); ?>" />
|
||||
<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', 'twentyten' ), 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' ); ?>" />
|
||||
|
|
Loading…
Reference in New Issue