Info
- 8 posts
- 4 voices
- Started 7 months ago by dominornovus
- Latest reply from kennymcnett
- This topic is not resolved
How do I edit bbPress breadcrumbs?
-
- Posted 7 months ago #
What I want to achieve:
I've installed bbPress as a plugin for WordPress. I want to make a few simple changes to the bbPress bread crumb function:bbp_breadcrumb();I need the bread crumb separator to be double right arrows rather than the default single arrow:
I want to replace > with ».I also want to add "You are here:"
Why I need this:
I need to match the styling and position the Yoast Breadcrumbs. Yoast Breadcrumbs is installed as a plugin for WordPress. It breaks on bbPress pages.
What I've tried:
Using conditions and CSS, I disabled the Yoast bread crumbs on bbPress pages. I also disabled the default bbPress bread crumbs but called it just beneath my primary navigation. Effectively, I've "moved" the bbPress bread crumbs.
To change the bread crumb separator I've researched JavaScript and jQuery string replacements but I've been advised that this is "hacky".
My question:
What's the conventional way of changing the output of bbPress function?
I can provide additional JavaScript, PHP and CSS code if required.
Live demo:
These two live examples highlights the two types of bread crumbs:
Yoast bread crumbs: http://www.directsponsor.org/forums/
bbPress bread crumbs: http://www.directsponsor.org/news/ -
- Posted 7 months ago #
I have come across an example of a filter to change the bread crumb separators but I can't seem to get it to work:
add_filter( 'breadcrumb_trail_args', 'my_breadcrumb_trail_args' );function my_breadcrumb_trail_args( $args ) {
$args['separator'] = ' → ';
return $args;
}
Source: http://themehybrid.com/support/topic/change-separator-breadcrumb#post-22852
-
- Posted 7 months ago #
I've found a list of hooks and filters for bbPress at:
/wp-content/plugins/bbpress/bbp-includes/bbp-core-hooks.phpI've also found the bbPress bread crumb function(s) at:
/wp-content/plugins/bbpress/bbp-includes/bbp-common-template.phpBy combining code from the two, I've attempted adding a filter but it's being ignored:
function test_args($args) {
$args = array(
'sep' => ' x ',
);
return $args;
}
add_filter('bbp_title','test_args');
-
- Posted 7 months ago #
In bbp-common-template.php I found:
// Allow the separator of the breadcrumb to be easily changed
$sep = apply_filters( 'bbp_breadcrumb_separator', $sep );
I attempted to apply a filter...
$sep = 'x';
add_filter('bbp_breadcrumb_separator', $sep);
...but it resulted in:
Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'x' was given in
-
- Posted 7 months ago #
I've figured out how to change the bread crumb separator:
// Change bbPress bread crumb separator.function filter_bbPress_breadcrumb_separator() {
//$sep = ' » ';
$sep = is_rtl() ? __( ' « ', 'bbpress' ) : __( ' » ', 'bbpress' );
return $sep;
}add_filter('bbp_breadcrumb_separator', 'filter_bbPress_breadcrumb_separator');
I have not yet figured out how to add "You are here: " at the start of the bread crumbs:
I've tried this...
function my_breadcrumb_trail_args( $trail ) {
$args['before'] = '<div class="bbp-breadcrumb"><p>You are here: ';
return $args;
};
add_filter( 'breadcrumb_trail_args', 'my_breadcrumb_trail_args' );
...and this...
function test($defaults) {
$defaults = array(
'before' => '<div class="bbp-breadcrumb"><p>You are here: ',
);
return $defaults;
}
add_filter('bbp_breadcrumb','test_args');
Neither work.
For now I've taken the hacky approach and just edited my bbPress files directly. You can see it in action here: http://www.directsponsor.org/forums/
Any assistance with the filter would be greatly appreciated.
-
- Posted 2 months ago #
I made a filter that set's the before, after, sep & root_text for the breadcrumbs. Take a look, writes over the 'bbp_get_breadcrumb_pre' filter found on line 1553 of bbp-includes/bbp-common-template.php
// Change bbPress bread crumb separator. function filter_bbp_breadcrumb( $args ) { $my_args = array( 'before' => "\n<div class=\"subnav bbp-breadcrumb \">\n <ul class=\"nav nav-pills \">\n <li>", 'after' => "</li>\n </ul>\n</div>\n\n", 'sep' => is_rtl() ? __( "</li>\n <li>", 'bbpress' ) : __( "</li>\n <li>", 'bbpress' ), 'root_text' => "Support" ); $args = wp_parse_args( $my_args, $args ); return $args; } add_filter('bbp_get_breadcrumb_pre', 'filter_bbp_breadcrumb' ); -
- Posted 2 months ago #
Yep thats correct. You can pick and choose the args if you don't want to reset all of them.
function custom_forum_breadcrumb( $args ) { $args['sep'] = ' | '; return $args; } add_filter( 'bbp_get_breadcrumb_pre', 'custom_forum_breadcrumb' ); -
- Posted 2 weeks ago #
Thanks mattsimo and jaredatch. Worked the charm.
Here are all of the $args and the defaults, FYI (pulled from bbPress core file: bbp-common-template.php)
// HTML 'before' => '<div class="bbp-breadcrumb"><p>', 'after' => '</p></div>', 'sep' => is_rtl() ? __( '‹', 'bbpress' ) : __( '›', 'bbpress' ), 'pad_sep' => 1, // Home 'include_home' => $pre_include_home, 'home_text' => $pre_front_text, // Forum root 'include_root' => $pre_include_root, 'root_text' => $pre_root_text, // Current 'include_current' => $pre_include_current, 'current_text' => $pre_current_text -
You must log in to post.