Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@amboutwe
Last active April 12, 2024 06:43
Show Gist options
  • Star 28 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save amboutwe/4b7a2f01366399281a53c355c5b78801 to your computer and use it in GitHub Desktop.
Save amboutwe/4b7a2f01366399281a53c355c5b78801 to your computer and use it in GitHub Desktop.
These snippets are examples of how you can modify the Yoast SEO breadcrumb visual output. These snippets will not alter the breadcrumb schema output. Please consult the schema documentation to change the breadcrumb schema: https://developer.yoast.com/features/schema/api#to-add-or-remove-graph-pieces
<?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;
}
@amboutwe
Copy link
Author

@foteinitaramonli These snippets are examples of how you can modify the Yoast SEO breadcrumb visual output (image below). These snippets will not alter the breadcrumb schema output nor will they alter WooCommerce's breadcrumb visual output.

Please consult the Yoast SEO schema documentation to change the breadcrumb schema. Please consult the WooCommerce breadcrumb documentation to change WooCommerce's breadcrumb output.

screenshot_519

@Apfelbiss
Copy link

Apfelbiss commented Apr 1, 2022

Hello,

thank you very much for these snippets.

But "$text_to_remove" does not work for text with an "&" in it.
I tried it with (all without blanks, of course):

  • &
  • & amp ;
  • & #x26 ;
  • & #38 ;

@cdils
Copy link

cdils commented Oct 25, 2022

If anyone needs an example of appending text to both a parent breadcrumb and a child breadcrumb, here's the gist and an accompanying tutorial.

@Saad876
Copy link

Saad876 commented Jun 26, 2023

I don't want to show Home on homepage how to disable that ?

@amboutwe
Copy link
Author

amboutwe commented Jul 7, 2023

@Saad876 This is not the proper place to request support. Please check out our extensive help section or visit the free support forum. If you require further support, upgrading to our premium version provides you with access to our support team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment