Skip to content

Instantly share code, notes, and snippets.

@janneleppanen
Last active September 3, 2020 06:49
Show Gist options
  • Save janneleppanen/3ce10bfb6c42936914be2695ef289f5b to your computer and use it in GitHub Desktop.
Save janneleppanen/3ce10bfb6c42936914be2695ef289f5b to your computer and use it in GitHub Desktop.
Polylang | Yoast | Breadcrumb - Archive link fix
function fix_breadcrumb_archive_links_lang( $links ) {
foreach ( $links as $key => $link ) {
if ( isset( $link['ptarchive'] ) ) {
$post_type_object = get_post_type_object( $link['ptarchive'] );
$links[$key]['url'] = get_post_type_archive_link( $link['ptarchive'] );
$links[$key]['text'] = $post_type_object->label;
}
}
return $links;
}
add_filter( 'wpseo_breadcrumb_links', 'fix_breadcrumb_archive_links_lang', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment