Skip to content

castlegateit/cgit-wp-breadcrumb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Castlegate IT WP Breadcrumb

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 list

Default text for front page and posts page

You 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.

Custom HTML

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>',
});

Functions

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);

License

Released under the MIT License. See LICENSE for details.

About

Simple breadcrumb navigation for WordPress

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages