breadcrumbspress_generator_build
This content is intended for WordPress developers, and it may require coding knowledge of WordPress, PHP, and JavaScript. Code examples provided here may contain errors or needs some additional coding. Make sure to test the code before using it on a live website!
Definition
Arguments
Returns
Filters a proposed current-request trail before the standard page-type builders run.
This hook is used when building the current-request trail. It is not a universal filter for trails generated directly for a specific post or term. The current generator caches a nonempty result for the request. This filter is skipped for the home and posts pages. When it returns a nonempty array, the standard fallback builders are skipped.
Example
This example registers a callback for the filter. Adapt the values and conditions to your site.
add_filter( 'breadcrumbspress_generator_build', function( $breadcrumbs ) {
if ( empty( $breadcrumbs ) && is_page( 'example-page' ) ) {
$breadcrumbs['custom'] = new \Dev4Press\Plugin\BreadcrumbsPress\Data\Crumb( array(
'title' => 'Example',
'current' => true,
) );
}
return $breadcrumbs;
}, 10, 1 );