5

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

0

5 Answers 5

3
+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.

3
  • 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, 2013 at 6:41
  • @its_me See my update.
    – fuxia
    Jan 10, 2013 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, 2013 at 17:17
4

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.

1
  • 1
    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.
    – shea
    Jan 7, 2013 at 23:29
3

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' );
6
  • 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, 2013 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. Jan 7, 2013 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, 2013 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. Jan 7, 2013 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, 2013 at 15:18
0

jQuery alternative if no plugin hook exists:

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

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';
        

1
  • 2
    -1 Because you are suggesting edits to a core file. This is not advisable.
    – its_me
    Jan 10, 2013 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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