How to change the text of link ‘Home’ in bbPress forum breadcrumb?

I just installed bbPress 2.0.2 forum plugin for WordPress, and would like to change the text of link Home to iGeek (or anything else, for that matter).

So the breadcrumb Home › Community becomes iGeek › Community (or something like that). How do I do that?

In case it helps, this is the code in \wp-content\plugins\bbpress\bbp-includes\bbp-common-template.php that determines the text:

/** Home Text *********************************************************/

// No custom home text
if ( empty( $args['home_text'] ) ) {

    // Set home text to page title
    if ( $front_id = get_option( 'page_on_front' ) ) {
        $pre_front_text = get_the_title( $front_id );

    // Default to 'Home'
    } else {
        $pre_front_text = __( 'Home', 'bbpress' );
    }
}

bbPress Breadcrumb

5 s
5

The string is now in bbpress/includes/common/template-tags.php.

Hook into bbp_no_breadcrumb, register a filter for gettext and change the text:

add_filter( 'bbp_no_breadcrumb', 'wpse_44597_change_home_text' );

function wpse_44597_change_home_text( $translated, $original="", $domain = '' )
{
    if ( 'bbp_no_breadcrumb' === current_filter() )
    {
        add_filter( 'gettext', __FUNCTION__, 10, 3 );
        return FALSE;
    }

    if ( 'Home' === $original && 'bbpress' === $domain )
    {
        remove_filter( current_filter(), __FUNCTION__ );
        return get_bloginfo( 'name' );
    }

    return $translated;
}

The difference to a filter on bbp_get_breadcrumb is: bbp_get_breadcrumb is the complete bread crumb, and it is really hard to find the string for the home page without touching the wrong matches. WordPress might be installed in /www/Home/wp/, or another item might contain the word Home. You do not want to touch that.

Leave a Comment