-
Notifications
You must be signed in to change notification settings - Fork 12
Breadcrumbs
Display breadcrumbs on your posts, and categories.
This module needs two things to work:
- It needs to be enabled in the Toolbelt Settings
- It needs to be implemented in the theme.
To keep speed high, Toolbelt only includes code for enabled modules. The breadcrumbs only work when the tb_breadcrumbs
function is called, but the function will not exist without the module being enabled.
In addition, by having a setting; themes that add support for breadcrumbs can still disable them whilst using other Toolbelt features.
To add to a theme I would suggest creating a new template function that looks something like:
function my_theme_breadcrumbs() {
if ( function_exists( 'toolbelt_breadcrumbs' ) ) {
toolbelt_breadcrumbs();
}
}
This reduces the likelihood of things breaking. If Toolbelt gets deleted, or the module disabled, then no errors will appear and the site will continue to work.
This filter allows you to hide the breadcrumbs on certain post or taxonomy types.
By default the value is false and breadcrumbs will be displayed if appropriate. Return true to hide the breadcrumbs.
For example to hide the breadcrumbs on pages, but show them everywhere else you could use:
function my_diplay_breadcrumbs() {
if ( is_page() ) {
return false;
}
return true;
}
add_filter( 'toolbelt_display_breadcrumbs', 'my_diplay_breadcrumbs' );
Filter the css classes that wrap the breadcrumbs.
function my_breadcrumb_css_class( $classes ) {
if ( is_page() ) {
$classes[] = 'paged-breadcrumbs';
}
return $classes;
}
add_filter( 'toolbelt_breacrumb_css_class', 'my_breadcrumb_css_class' );
Toolbelt is built by Ben from Pro Theme Design.