[theme-reviewers] Usage of wp_title filter.

Philip M. Hofer (Frumph) philip at frumph.net
Wed Oct 17 14:27:17 UTC 2012

That is precisely how to do it.  But you should also return the original 
$title being passed through the filter

This is how I do it (not totally pretty), notice the check for the feed if 
it is the feed it returns the original $title .. I probably could have 
gotten away with just doing = .= with $title in the !is_feed() section ;/

function easel_filter_wp_title( $title ) {
    global $wp_query, $s, $paged, $page;
    if (!is_feed()) {
        $sep = __('»','easel');
        $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','easel'), 
        } else
            $new_title .= $title;
        if ( $paged || $page ) {
            $new_title .= ' '.$sep.' '.sprintf(__('Page: %s','easel'),max( 
$paged, $page ));
        $title = $new_title;
    return $title;

add_filter( 'wp_title', 'easel_filter_wp_title' );

-----Original Message----- 
From: esmi at quirm dot net
Sent: Wednesday, October 17, 2012 7:16 AM
To: theme-reviewers at lists.wordpress.org
Subject: [theme-reviewers] Usage of wp_title filter.

I've just been reviewing the Codex page on the wp_title() filter:


Specifically the example quoted as best practice. When I've tried to
implement that function, it generates a duplicated title in the RSS
feed. This can be circumvented by changing:

return get_bloginfo( 'name' ) . $page_type . $title . $page_num;


if( !is_feed() ) return get_bloginfo( 'name' ) . $page_type . $title .

but I'm not 100% convinced that this is the proper usage of is_feed().

Anyone care to comment before I amend the Codex page?

theme-reviewers mailing list
theme-reviewers at lists.wordpress.org

More information about the theme-reviewers mailing list