From this comment:
I know the title could be defined in the header.php file as but I din’t want to touch the existing header.php, but do it in a child theme’s functions.php instead
But Twenty Twelve isn’t modifying the separator in its wp_title
filter callback; rather, it is defining it in its call to wp_title()
, in header.php
:
<title><?php wp_title( '|', true, 'right' ); ?></title>
Note that the wp_title
callback merely passes $sep
along, without modifying it:
function twentytwelve_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', 'twentytwelve' ), max( $paged, $page ) );
return $title;
}
add_filter( 'wp_title', 'twentytwelve_wp_title', 10, 2 );
You have two choices:
-
Replace
header.php
via Child Theme, and call:<title><?php wp_title( '-', true, 'right' ); ?></title>
-
Remove Twenty Twelve’s filter callback, and replace it with your own:
function wpse87673_filter_wp_title( $title, $sep ) { // Your callback code goes here } add_filter( 'wp_title', 'wpse87673_filter_wp_title', 11, 2 ); remove_filter( 'wp_title', 'twentytwelve_wp_title', 10, 2 );
I don’t think there is a more simple way to filter $sep
directly. It is defined by the wp_title()
function call parameter.