diff --git a/wp-content/themes/twentyten/functions.php b/wp-content/themes/twentyten/functions.php
index cc45a2472b..017e720545 100644
--- a/wp-content/themes/twentyten/functions.php
+++ b/wp-content/themes/twentyten/functions.php
@@ -191,35 +191,71 @@ function twentyten_admin_header_style() {
tag, by filtering the output of wp_title().
*
- * Used in Twenty Ten's header.php to add the page number to the
HTML tag.
+ * If we have a site description and we're viewing the home page or a blog posts
+ * page (when using a static front page), then we will add the site description.
+ *
+ * If we're viewing a search result, then we're going to recreate the title entirely.
+ * We're going to add page numbers to all titles as well, to the middle of a search
+ * result title and the end of all other titles.
+ *
+ * The site title also gets added to all titles.
*
* @since Twenty Ten 1.0
+ *
+ * @param string $title Title generated by wp_title()
+ * @param string $separator The separator passed to wp_title(). Twenty Ten uses a
+ * vertical bar, "|", as a separator in header.php.
+ * @return string The new title, ready for the tag.
*/
-function twentyten_the_page_number() {
- global $paged; // Contains page number.
- if ( $paged >= 2 )
- echo ' | ' . sprintf( __( 'Page %s', 'twentyten' ), $paged );
+function twentyten_filter_wp_title( $title, $separator ) {
+ // The $paged global variable contains the page number of a listing of posts.
+ // The $page global variable contains the page number of a single post that is paged.
+ // We'll display whichever one applies, if we're not looking at the first page.
+ global $paged, $page;
+
+ if ( is_search() ) {
+ // If we're a search, let's start over:
+ $title = sprintf( __( 'Search results for %s', 'twentyten' ), '"' . get_search_query() . '"' );
+ // Add a page number if we're on page 2 or more:
+ if ( $paged >= 2 )
+ $title .= " $separator " . sprintf( __( 'Page %s', 'twentyten' ), $paged );
+ // Add the site name to the end:
+ $title .= " $separator " . get_bloginfo( 'name', 'display' );
+ // We're done. Let's send the new title back to wp_title():
+ return $title;
+ }
+
+ // Otherwise, let's start by adding the site name to the end:
+ $title .= get_bloginfo( 'name', 'display' );
+
+ // If we have a site description and we're on the home/front page, add the description:
+ $site_description = get_bloginfo( 'description', 'display' );
+ if ( $site_description && ( is_home() || is_front_page() ) )
+ $title .= " $separator " . $site_description;
+
+ // Add a page number if necessary:
+ if ( $paged >= 2 || $page >= 2 )
+ $title .= " $separator " . sprintf( __( 'Page %s', 'twentyten' ), max( $paged, $page ) );
+
+ // Return the new title to wp_title():
+ return $title;
}
-endif;
+add_filter( 'wp_title', 'twentyten_filter_wp_title', 10, 2 );
/**
* Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
diff --git a/wp-content/themes/twentyten/header.php b/wp-content/themes/twentyten/header.php
index b58a358d55..fbd2486055 100644
--- a/wp-content/themes/twentyten/header.php
+++ b/wp-content/themes/twentyten/header.php
@@ -11,31 +11,19 @@
?>
>
-
-
-
-
-
-
-
+
+ tag based on what is being viewed.
+ * We filter the output of wp_title() a bit -- see
+ * twentyten_filter_wp_title() in functions.php.
+ */
+ wp_title( '|', true, 'right' );
+
+ ?>
+
+
+
such
* as styles, scripts, and meta tags.
*/
-
wp_head();
?>