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'm trying to edit just a few pieces of bbpress' breadcrumb default settings, but the filters I've tried end up replacing the whole function. How do you replace only bits? Here is the filter as it stands now

function custom_bbp_breadcrumb() {
    $args = array (
        'before'  => '<div class="bbp-breadcrumb">',
        'after'   => '</div>',
        'sep'     => __( '&rsaquo;', 'bbpress' ),
    );
    return $args;
}

add_filter('bbp_get_breadcrumb', 'custom_bbp_breadcrumb' );

I could copy + paste the whole function and filter that, but that would be extremely inefficient.

share|improve this question
    
Why was my question down voted? You should at least include a comment as to what the issue is. –  Kristina Childs Dec 20 '12 at 0:05
add comment

1 Answer

up vote 0 down vote accepted

Looks like that isn't the filter the want. It runs right at the end of the BBPress bbp_get_breadcrumb function which is after the stuff you want to change.

You can change just the separator with bbp_breadcrumb_separator and it looks like before and after can be set with bbp_get_breadcrumb_pre. In fact, it looks like you should be able to use that last filter for all of them.

I don't run BBPress so this is untested but what you want probably looks like:

function custom_bbp_breadcrumb() {
    $args['before']  = '<div class="bbp-breadcrumb">';
    $args['after']   = '</div>';
    $args['sep']     = __( '&rsaquo;', 'bbpress' );
    return $args;
}
add_filter('bbp_before_get_breadcrumb_parse_args', 'custom_bbp_breadcrumb' );

What you were doing with your filter function was completely erasing the input. You created a brand new array inside your filter function and sent that new array back out. What the modified filter does is take the input, alter it, and give it back with only some parts changed and everything else left alone.

share|improve this answer
    
This has syntax errors in it that results in a blank page. I'm not sure what syntax errors since I'm still learning this stuff... –  Kristina Childs Dec 19 '12 at 23:42
    
I see the errors. :( Give me a second. I didn't replace the commas with semi-colons. –  s_ha_dum Dec 19 '12 at 23:44
1  
It turns out the filter target was bbp_before_get_breadcrumb_parse_args and no $args is needed in the filter name. I have zero idea why that filter works. I can't find it anywhere in bbpress' functions... I guess I just don't understand fully how these things work yet. If you adjust your anser I'll mark it the solution. –  Kristina Childs Dec 20 '12 at 0:23
    
I can't find that hook in the source code either. I am puzzled by that too. –  s_ha_dum Dec 20 '12 at 0:51
    
Glad it's not just me. I feel like I'm in bizzarroland –  Kristina Childs Dec 20 '12 at 1:12
add comment

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.