Created
October 17, 2012 18:44
-
-
Save grayghostvisuals/3907306 to your computer and use it in GitHub Desktop.
This approach was posted via theme reviewers mailing list and unanimously agreed upon as the correct implementation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wpflex_filter_wp_title( $title ) { | |
global $wp_query, $s, $paged, $page; | |
if ( !is_feed() ) { | |
$sep = __('»'); | |
$new_title = get_bloginfo('name').' '; | |
$bloginfo_description = get_bloginfo('description'); | |
if ((is_home () || is_front_page()) && !empty($bloginfo_description) && !$paged && !$page) { | |
$new_title .= $sep.' '.$bloginfo_description; | |
} | |
elseif (is_single() || is_page()) { | |
$new_title .= $sep.' '.single_post_title('', false); | |
} | |
elseif (is_search() ) { | |
$new_title .= $sep.' '.sprintf(__('Search Results: %s'), | |
esc_html($s)); | |
} | |
else | |
$new_title .= $title; | |
if ( $paged || $page ) { | |
$new_title .= ' '.$sep.' '.sprintf(__('Page: %s'),max( $paged, | |
$page )); | |
} | |
$title = $new_title; | |
} | |
return $title; | |
} | |
add_filter( 'wp_title', 'wpflex_filter_wp_title' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment