WordPress Breadcrumbs using the Menu Structure Question
-
I know there are several questions regard using the menu hierarchy (instead of parent/child status) for breadcrumbs and I did the following… Stay with me… there is a question 🙂
I added this code to my theme’s functions file:
/** Breadcrumbs from Menu Structure -----------------------------------------------------------*/ function menu_breadcrumbs($theme_location = 'main', $separator = ' » ') { $items = wp_get_nav_menu_items($theme_location); _wp_menu_item_classes_by_context( $items ); // Set up the class variables, including current-classes $crumbs = array(); foreach($items as $item) { if ($item->current_item_ancestor || $item->current) { $crumbs[] = "<a href=\"{$item->url}\" title=\"{$item->title}\">{$item->title}</a>"; } } echo implode($separator, $crumbs); }
Then I added this to the page template:
<?php menu_breadcrumbs('primary-menu'); ?>
All this works, BUT… I really need the breadcrumbs to show all options for each main category, if that makes sense…
For examples on my events page (http://www.sciotomile.com/events/), the code above creates a breadcrumb trail consisting of the main category and then the current page (like this: Events >> Events Calendar). For many sites this would be perfect, but my site doesn’t have any subpages of subpages (in other words there are only 2 levels to my page structure). So I would like the breadcrumbs to show all options under the current category or tier and then underline or bold or whatever the current page…
So instead of this:
Events >> Events Calendar
I would see this:
Events >> Events Calendar >> Rhythm on the River >> FountainSide >> Jazz & Rib Fest >> Grand Illumination >> Plan an Event
I would also like to see the option for “Home” provided…
Anyway, if anyone can help me, I would really appreciate it 🙂
- The topic ‘WordPress Breadcrumbs using the Menu Structure Question’ is closed to new replies.