How To Add Current Page To Breadcrumbs in Drupal 7

By February 14, 2017Blog, CMS, Drupal
Allure Web Solutions Code Snippet

By default, Drupal 7 doesn’t include the current page in the breadcrumbs trail. The snippet below shows how to add the current page to the breadcrumb in Drupal 7. The current page will remain unlinked.

function THEME-NAME_breadcrumb($variables)
    $breadcrumb = $variables['breadcrumb'];
    // If breadcrumbs are activated
    if (!empty($breadcrumb)) {
        $title = drupal_get_title();
        if (!empty($title)) {
            $breadcrumb[] = $title;
        return '<div class="breadcrumb">' . implode(' › ', $breadcrumb) . '</div>';

Where THEME-NAME is the name of your theme. This code will auto-execute as it hooks into your theme.

Add this snippet to: theme_folder/themes/

Mike Doubintchik

Author Mike Doubintchik

More posts by Mike Doubintchik

Leave a Reply