Skip to content

Instantly share code, notes, and snippets.

@peterwegren
Last active November 16, 2016 17:21
Show Gist options
  • Save peterwegren/45968e147ba53f700e1b8ad8469c05df to your computer and use it in GitHub Desktop.
Save peterwegren/45968e147ba53f700e1b8ad8469c05df to your computer and use it in GitHub Desktop.
Add CPT permalink base to breadcrumbs
<?php
/*
* Add CPT base to breadcrumbs
*/
function my_wpseo_breadcrumb_links( $links ) {
if ( is_single() ) {
$cpt_object = get_post_type_object( get_post_type() );
if ( ! $cpt_object->_builtin ) {
$landing_page = get_page_by_path( $cpt_object->rewrite['slug'] );
array_splice( $links, -2, 1, array( array( 'id' => $landing_page->ID ) ));
}
}
return $links;
}
add_filter( 'wpseo_breadcrumb_links', 'my_wpseo_breadcrumb_links' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment