Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save apsolut/f12ff3ff5d554b2a086c4ed89e94701b to your computer and use it in GitHub Desktop.
Save apsolut/f12ff3ff5d554b2a086c4ed89e94701b to your computer and use it in GitHub Desktop.
Remove link from the Yoast SEO breadcrumbs site wide
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/*
* Remove the last breadcrumb, the post name, from the Yoast SEO breadcrumbs
* Previous breadcrumb link will become text
* Credit: Jason @ http://thejasonjones.com/wordpress-seo-breadcrumbs-tweaks/
* Last Tested: Jun 11 2018 using Yoast SEO 7.6.1 on WordPress 4.9.6
*/
add_filter( 'wpseo_breadcrumb_links', 'wpseo_breadcrumb_remove_postname' );
function wpseo_breadcrumb_remove_postname( $links ) {
if( sizeof($links) > 1 ){
array_pop($links);
}
return $links;
}
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/*
* Remove the last breadcrumb, the post title, from the Yoast SEO breadcrumbs
* Previous breadcrumb will remain linked
* Credit: David @ https://generatepress.com/forums/topic/how-to-hide-the-title-part-in-the-breadcrumb-im-using-yoast-seo/#post-614239
* Last Tested: Apr 11 2020 using Yoast SEO 13.4.1 on WordPress 5.4
*/
add_filter('wpseo_breadcrumb_single_link', 'remove_breadcrumb_title' );
function remove_breadcrumb_title( $link_output) {
if(strpos( $link_output, 'breadcrumb_last' ) !== false ) {
$link_output = '';
}
return $link_output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment