BuddyPress and WordPress SEO titles

Last week, before the first WordUp Pompey (which I have yet to write anything about) I wrote to the WordCamp UK list reporting a problem with my SEO titles. I thought it was something to do with not configuring wordpress-seo correctly.


page titles have the blogname twice and two vertical bars. e.g. active plugins || WP-PompeyWP-Pompey

which doesn’t look right now does it?

As appears to be often the case, I developed my own fix before finding that someone else had done the same sort of thing. e.g. making BuddyPress compatible with the WordPress SEO plugin

My fix was slightly different… since I had a similar problem, with a theme that had been generated by Artisteer. The generated code contained: wp_title( '|', true, 'right' ); bloginfo( 'name' );

My solution

Change the line in header.php to “echo bw_wp_title();” Add a function called bw_wp_title() in the theme’s functions.php file Write the function as below.

 * return a nice SEO title
 * taking into account which plugins are being used
if ( !function_exists( 'bw_wp_title' )) {
  function bw_wp_title() {
    if ( class_exists( 'WPSEO_Frontend' )) {
      $title = wp_title('', false );
    }else {
      $title = wp_title( '|', false, 'right' ); 
      $title .= get_bloginfo( 'name' );
    return $title;

I’m going to include the function into my oik plugin, so that I can extend it as and when necessary. There are probably much better ways of doing this. This is a pragmatic solution.