Forum Replies Created

Viewing 1 replies (of 1 total)
  • Hey, I think I found a solution for this issue at my site (www.mude.nu).

    I am using the most recent versions of Buddypress (1.6.1) and WordPress SEO by Yoast (1.2.8.5).

    It´s not a elegant solution, because I´m not a programmer, but it´s working. I´m sharing to see if I get some improvements.

    So, to make Buddypress titles work while WordPress SEO by Yoast plugin is activated, just add this to your theme´s functions.php:

    <br />
    add_filter('wpseo_title', 'mood_bp_title');<br />
    function mood_bp_title($title) {<br />
    if ( function_exists('bp_current_component') && bp_current_component() ) {<br />
    global $bp;</p>
    <p>  // If this is not a BP page, just return the title produced by WP<br />
      if ( bp_is_blog_page() )<br />
        return $title;</p>
    <p>  // If this is the front page of the site, return WP's title<br />
      if ( is_front_page() || is_home() )<br />
        return $title;</p>
    <p>  $title = '';</p>
    <p>  // Displayed user<br />
      if ( bp_get_displayed_user_fullname() && !is_404() ) {</p>
    <p>    // Get the component's ID to try and get it's name<br />
        $component_id = $component_name = bp_current_component();</p>
    <p>    // Use the actual component name<br />
        if ( !empty( $bp->{$component_id}->name ) ) {<br />
          $component_name = $bp->{$component_id}->name;</p>
    <p>    // Fall back on the component ID (probably same as current_component)<br />
        } elseif ( !empty( $bp->{$component_id}->id ) ) {<br />
          $component_name = $bp->{$component_id}->id;<br />
        }</p>
    <p>    // Construct the page title. 1 = user name, 2 = seperator, 3 = component name<br />
        $title = strip_tags( sprintf( _x( '%1$s %3$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 ) );</p>
    <p>  // A single group<br />
      } elseif ( bp_is_active( 'groups' ) && !empty( $bp->groups->current_group ) && !empty( $bp->bp_options_nav[$bp->groups->current_group->slug] ) ) {<br />
        $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'] : '';<br />
        // translators: "group name | group nav section name"<br />
        $title = sprintf( __( '%1$s | %2$s', 'buddypress' ), $bp->bp_options_title, $subnav );</p>
    <p>  // A single item from a component other than groups<br />
      } elseif ( bp_is_single_item() ) {<br />
        // translators: "component item name | component nav section name | root component name"<br />
        $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() ) );</p>
    <p>  // An index or directory<br />
      } elseif ( bp_is_directory() ) {<br />
        if ( !bp_current_component() ) {<br />
          $title = sprintf( __( '%s Directory', 'buddypress' ), bp_get_name_from_root_slug() );<br />
        } else {<br />
          $title = sprintf( __( '%s Directory', 'buddypress' ), bp_get_name_from_root_slug() );<br />
        }</p>
    <p>  // Sign up page<br />
      } elseif ( bp_is_register_page() ) {<br />
        $title = __( 'Create an Account', 'buddypress' );</p>
    <p>  // Activation page<br />
      } elseif ( bp_is_activation_page() ) {<br />
        $title = __( 'Activate your Account', 'buddypress' );</p>
    <p>  // Group creation page<br />
      } elseif ( bp_is_group_create() ) {<br />
        $title = __( 'Create a Group', 'buddypress' );</p>
    <p>  // Blog creation page<br />
      } elseif ( bp_is_create_blog() ) {<br />
        $title = __( 'Create a Site', 'buddypress' );<br />
      }</p>
    <p>  // Some BP nav items contain item counts. Remove them<br />
      $title = preg_replace( '|<span>[0-9]+</span>|', '', $title ); }</p>
    <p>  return apply_filters( 'bp_modify_page_title', $title . ' ' . $sep . ' ', $title, $sep, $seplocation );<br />
    }<br />

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your code has been permanently damaged/corrupted by the forum’s parser.]

Viewing 1 replies (of 1 total)