Skip to content

Instantly share code, notes, and snippets.

@patric-boehner
Last active December 15, 2018 05:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patric-boehner/613bd72f14c1c38d2478bfb6151f417b to your computer and use it in GitHub Desktop.
Save patric-boehner/613bd72f14c1c38d2478bfb6151f417b to your computer and use it in GitHub Desktop.
Change Genesis theme breadcrumbs for parent page using specific page template
<? php
// Don't include opening php tag
// Filter breadcrumbs for parent template pages
add_filter( 'genesis_page_crumb', 'pb_change_parent_page_template_title_for_breadcrumb' );
function pb_change_parent_page_template_title_for_breadcrumb( $crumb ) {
// If not our specificed page template, abort.
if ( ! is_page_template( 'templates/page-book.php' ) ) {
return $crumb;
}
global $post;
// Get the title of the parent page
$parent_title = get_the_title( $post->post_parent );
// To make this better i might pull in the title of this pages menu item so they match
$breadcrumb_title = esc_html__( 'Books', 'your-theme' );
// Adjust the breadcrumb.
$crumb = str_replace( $parent_title, $breadcrumb_title, $crumb );
return $crumb;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment