Support » Plugin: Yoast SEO » Buddypress Double Titles Bug

  • Hello,

    Im running a buddypress 1.6.2 install and your plugin is causing duplicate titles on the buddypress profile pages. Can you help us figure it out?

    I used this from another wp users suggestion and and seemed to work ok

    add_filter(‘wpseo_title’, ‘mood_bp_title’);
    function mood_bp_title($title) {
       if ( function_exists(‘bp_current_component’) && bp_current_component() ) {
           global $bp;

           $sep = “|”;

           // If this is not a BP page, just return the title produced by WP
           if ( bp_is_blog_page() )
           return $title;
           
           // If this is the front page of the site, return WP’s title
           if ( is_front_page() || is_home() )
               return $title;
               $title = ”;
           
           // Displayed user
           if ( bp_get_displayed_user_fullname() && !is_404() ) {
               // Get the component’s ID to try and get it’s name
               $component_id = $component_name = bp_current_component();

           if ( !empty( $bp->{$component_id}->name ) ) {
               // Use the actual component name
               $component_name = $bp->{$component_id}->name;
           } elseif ( !empty( $bp->{$component_id}->id ) ) {
               // Fall back on the component ID (probably same as current_component)
               $component_name = $bp->{$component_id}->id;
           }
               // Construct the page title. 1 = user name, 2 = seperator, 3 = component name
               $title = strip_tags( sprintf( _(angry) ‘%1$s | %2$s’, ‘Construct the page title. 1 = user name, 2 = component name, 3 = seperator’, ‘buddypress’ ), bp_get_displayed_user_fullname(), ucwords( $component_name ), $sep ) );
           } elseif ( bp_is_active( ‘groups’ ) && !empty( $bp->groups->current_group ) && !empty( $bp->bp_options_nav[$bp->groups->current_group->slug] ) ) {
               // A single group
               $subnav = isset( $bp->bp_options_nav[$bp->groups->current_group->slug][bp_current_action()][‘name’] ) ? $bp->bp_options_nav[$bp->groups->current_group->slug][bp_current_action()][‘name’] : ”;

               // translators: “group name | group nav section name”
               $title = sprintf( __( ‘%1$s | %2$s’, ‘buddypress’ ), $bp->bp_options_title, $subnav );

           } elseif ( bp_is_single_item() ) {
               // A single item from a component other than groups
               // translators: “component item name | component nav section name | root component name”
               $title = sprintf( __( ‘%1$s | %2$s | %3$s’, ‘buddypress’ ), $bp->bp_options_title, $bp->bp_options_nav[bp_current_item()][bp_current_action()][‘name’], bp_get_name_from_root_slug( bp_get_root_slug() ) );
               
           } elseif ( bp_is_directory() ) {
               // An index or directory
               if ( !bp_current_component() ) {
                   $title = sprintf( __( ‘%s Directory’, ‘buddypress’ ), bp_get_name_from_root_slug() );
               } else {
                   $title = sprintf( __( ‘%s Directory’, ‘buddypress’ ), bp_get_name_from_root_slug() );
               }
       
           } elseif ( bp_is_register_page() ) {
               // Sign up page
               $title = __( ‘Create an Account’, ‘buddypress’ );
           } elseif ( bp_is_activation_page() ) {
               // Activation page
               $title = __( ‘Activate your Account’, ‘buddypress’ );
           } elseif ( bp_is_group_create() ) {
               // Group creation page
               $title = __( ‘Create a Group’, ‘buddypress’ );
           } elseif ( bp_is_create_blog() ) {
               // Blog creation page
               $title = __( ‘Create a Site’, ‘buddypress’ );
           }
       
           // Some BP nav items contain item counts. Remove them
           $title = preg_replace( ‘|<span>[0-9]+</span>|’, ”, $title ); }
           
       return apply_filters( ‘bp_modify_page_title’, $title . ‘ ‘ . $sep . ‘ ‘, $title, $sep, $seplocation );
    }

    http://wordpress.org/extend/plugins/wordpress-seo/

  • The topic ‘Buddypress Double Titles Bug’ is closed to new replies.