In the members-only forum, a user asked:
I wonder if it’s possible to change the genesis breadcrumbs function to use the menu label instead of the page title – (without using a plugin like Yoast or Nexxt Breadcrumbs)?
So far, all my searches have come up mostly empty. The only two somewhat useful posts I’ve been able to find are
How to Modify / Customize Genesis Framework Breadcrumbs for your WordPress Blog?
(step 4) > and
Want to do a tutorial for us? 🙂 > If a menu label has been set, we should use that, if not – just use the page title instead.
By default, the last bit of breadcrumbs on static Pages will show the current Page title.
Let's say you are viewing a static Page titled
Contact and you have added it in your navigation menu. With breadcrumbs enabled for Pages in Genesis theme settings, it's going to appear like this in the front end:
Now if the Navigation Label of the menu item is changed to say,
Contact Us, the breadcrumb will continue to show the Page title.
If you'd like the breadcrumb to also read
Contact Us, the easiest option is to edit the Page and change its title. If for whatever reason you don't want to/can't do that,
genesis_page_crumb filter hook can be used to set the Page breadcrumb to nav menu item label if present, else the default title, including any parent breadcrumbs.
In a custom function hooked to
genesis_page_crumb, we are going to
- define an empty
- store the name of the nav menu in a
- store all menu items of the above navigation menu in a
- for each menu item, check if it points/links to the current Page and if so, set the Page title in
$menu_item_labelvariable and break out of the loop.
$menu_item_labelis not empty, set it as the crumb else the default.
Add the following in child theme's
To view the full content, please sign up for the membership.
Already a member? Log in below or here.