Breadcrumb Trail is a plugin that displays a breadcrumb menu on your site. Plain and simple.
How is it any better than any other breadcrumb plugin? Well, it’s probably not, to be perfectly honest. This is just a script I’ve been building upon for several years that I usually include with my WordPress themes. I figured I’d package it as a plugin for others to use as well.
How to install the plugin
- Uzip the
breadcrumb-trail.zip
folder. - Upload the
breadcrumb-trail
folder to your/wp-content/plugins
directory. - In your WordPress dashboard, head over to the Plugins section.
- Activate Breadcrumb Trail.
How to use the plugin
This plugin won’t work automatically because there’s no way for me to know where it should show within your theme. So, you’ll have to add it manually in your template files. Where? Well, that’s really up to you. You can add it pretty much anywhere you want.
This is the basic code:
<?php breadcrumb_trail(); ?>
The default parameters
By default, this plugin is designed to show things a certain way. Here are the defaults:
$defaults = array(
'separator' => '/',
'before' => '<span class="breadcrumb-title">' . __('Browse:', 'breadcrumb_trail') . '</span>',
'after' => false,
'front_page' => true,
'show_home' => __('Home', 'breadcrumb_trail'),
'singular_{$post_type}_taxonomy' => false,
'echo' => true,
);
separatorThe element that separates each item in the breadcrumb menu.beforeWhat should be shown before the trail.afterWhat should be shown after the trail.show_homeThe text for the home link. Set to false
if no home link is needed.singular_{$post_type}_taxonomyA taxonomy to use as part of the leading trail on singular views of specific post types.echoWhether to print on the screen or return for use in a function.
Custom examples
Let’s change the text before the breadcrumb trail.
<?php breadcrumb_trail( array( 'before' => 'You are here »' ) ); ?>
How about we change the separator between each item?
<?php breadcrumb_trail( array( 'separator' => '→' ) ); ?>
This time, we’ll wrap the entire menu in brackets.
<?php breadcrumb_trail( array( 'before' => '{', 'after' => '}' ) ); ?>
Now, let’s add post tags as part of the trail for singular posts.
<?php breadcrumb_trail( array( 'singular_post_taxonomy' => 'post_tag' ) ); ?>
Pretty simple stuff, right? Just mix and match the parameters however you want.
Protect yourself from errors in the future
Sometimes, we stop using plugins, but we forget to remove the function calls to the plugins in our theme files. When deactivated, this causes errors. To protect yourself from these errors, you can call the breadcrumb trail like this:
<?php if ( function_exists( 'breadcrumb_trail' ) ) { breadcrumb_trail(); } ?>
Basically, this just checks to see if the plugin is activated and has loaded the appropriate function.
Styling your breadcrumb trail
Breadcrumb Trail comes with some extra classes to work with, so you can have a bit of freedom when styling your menu. Here are the CSS classes for your use:
.breadcrumb {
/* This is the outer 'div' you can style */
}
.breadcrumb-trail {
/* This is the inner 'div' you can style */
}
Developer tools
If you’re a theme developer, you can always add checks for this plugin and place it yourself within your template files or use add_action()
to add it to a custom theme hook.
This plugin has three filter hooks for use as well:breadcrumb_trail_argsOverwrite the arguments input and/or the defaults.breadcrumb_trailCompletely overwrite the entire breadcrumb menu.breadcrumb_trail_itemsOverwrite or extend the rrray of items shown in the trail.
Plugin support
I run a WordPress community called Theme Hybrid, which is where I fully support all of my WordPress projects, including plugins. You can sign up for an account to get plugin support for a small yearly fee ($25 USD at the time of writing).
I know. I know. You might not want to pay for support, but just consider it a donation to the project. To continue making cool, GPL-licensed plugins and having the time to support them, I must pay the bills.
Copyright & license
Breadcrumb Trail is licensed under the GNU General Public License, version 2 (GPL).
This plugin is copyrighted to Justin Tadlock.