Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question

5 Answers 5

up vote 3 down vote accepted
+50

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.

share|improve this answer
    
One question - is hooking into bbp_no_breadcrumb better than using bbp_get_breadcrumb as bungeshea's answer shows? or it just doesn't matter either way? –  its_me Jan 10 '13 at 6:41
    
@its_me See my update. –  toscho Jan 10 '13 at 10:57
    
(Considering your edit) If that is so, Bounty is yours! And people shouldn't be upvoting that answer. –  its_me Jan 10 '13 at 17:17

There is no specific hook to filter the home text only, so we need to filter the whole breadcrumb and replace 'Home' with 'iGeek':

function wpse_44597_custom_home_text_in_bbp_breadcrumb( $trail ) {
    return str_ireplace( 'Home', 'iGeek', $trail );
}
add_filter( 'bbp_get_breadcrumb', 'wpse_44597_custom_home_text_in_bbp_breadcrumb' );

The above example has been successfully tested on my own site running bbPress 2.2.3.

share|improve this answer
    
Note that in bbPress 2.2.3, the part that generates the home text (as referenced in the question) is located in includes/common/template-tags.php on line 1876. –  bungeshea Jan 7 '13 at 23:29

There are two possibilities, depending what theme you are using:

1 Locate call to bbp_breadcrumb or bbp_get_breadcrumb function in your template files and add arguments to your function, like this:

$args = array(
    'home_text' => 'iGeek'
);
bbp_breadcrumb( $args );
// or bbp_get_breadcrumb( $args ), depending on which theme has been used in the first place

2 Create a page that you will use as your home page (depends on weather your theme supports such functionality or not; if there is a page template available for homepage then select it), name it 'iGeek'. Go to Reading -> Settings in your WP admin, select 'Static page' in 'Front page displays' option and select your 'iGeek' page as front page. Save options and the link in breadcrumb should change its name. This may change the way your home page is displayed and can vary from theme to theme.

I suggest trying the former method first.

EDIT:

I have found another method to do that - put below code in your functions.php:

function modify_breadcrumb_args() {
    $args['home_text'] = 'iGeek';

    return $args;
}

add_filter( 'bbp_before_get_breadcrumb_parse_args', 'modify_breadcrumb_args' );
share|improve this answer
    
There's no theme. I am using the default one with custom CSS. So, could you edit your answer w.r.t that? –  its_me Jan 7 '13 at 14:27
    
@its_me So are you using TwentyEleven/Twelve, their versions that came with bbPress or a custom theme that doesn't have any of the bbPress template files bundled with it? Anyway, try the second option. –  Mateusz Hajdziony Jan 7 '13 at 14:55
    
#2 - using a custom theme that doesn't have any of the bbPress template files bundled with it. –  its_me Jan 7 '13 at 15:09
    
@its_me Then the second option will work. It will actually work for any theme, but for some themes you may need some additional tweaks to display what you previously had on the home page, it just depends on how the theme was built. –  Mateusz Hajdziony Jan 7 '13 at 15:16
    
If I remember it right, I actually tried the #2 option, and then dumped it due to some issues (i.e. it was making something else difficult). Anyway, I'll keep this in mind. Thanks for the input. –  its_me Jan 7 '13 at 15:18

jQuery alternative if no plugin hook exists:

<script type="text/javascript">
    jQuery(document).ready( function($) {
        $('#bborg-crumbs a:first').html('iGeek');
    });
</script>
share|improve this answer

I found out how to change the breadcrumb url, alt and text myself. You can change the code in bbp-common-template.php (/wp-content/plugins/bbpress/bbp-includes/bbp-common-template.php) on line 1889

 // Add the breadcrumb
        $crumbs[] = 'iGeek';
        

share|improve this answer
1  
-1 Because you are suggesting edits to a core file. This is not advisable. –  its_me Jan 10 '13 at 17:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.