Castlegate IT WP Breadcrumb adds a simple breadcrumb navigation to WordPress. The Castlegate\Breadcrumb\Breadcrumb class can generate breadcrumb items as an array of data, an array of HTML links, or a complete breadcrumb navigation:
use Castlegate\Breadcrumb\Breadcrumb;
$crumb = new Breadcrumb();
$foo = $crumb->getItems(); // return array of items
$foo = $crumb->getLinks(); // return array of HTML links
$foo = $crumb->render($sep); // return HTML links separated by $sep
$foo = $crumb->renderList($tag); // return HTML listYou can specify the text used for the home page and the posts index in the constructor:
$crumb = new Breadcrumb([
'home' => 'Home',
'index' => 'News',
]);You can also use the cgit_breadcrumb_names filter to edit the array of front and posts page names.
You can customize the HTML used for links, non-links, and the current breadcrumb item using a filter, with sprintf strings as templates:
add_filter('cgit_breadcrumb_templates', function ($templates) {
'url' => '<a href="%2$s" class="cgit-breadcrumb-item link">%1$s</a>',
'current' => '<span class="cgit-breadcrumb-item current">%s</span>',
'span' => '<span class="cgit-breadcrumb-item span">%s</span>',
});For backwards compatibility, the plugin also provides a function for rendering a breadcrumb navigation, equivalent to the render method:
$foo = cgit_breadcrumb($sep, $home, $index);Released under the MIT License. See LICENSE for details.