Skip to content

Instantly share code, notes, and snippets.

@davevanhoorn
Created August 3, 2018 05:10
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davevanhoorn/12def715575dafc35f6c008b76bd9d61 to your computer and use it in GitHub Desktop.
Save davevanhoorn/12def715575dafc35f6c008b76bd9d61 to your computer and use it in GitHub Desktop.
Remove "Products" from Yoast SEO breadcrumbs in WooCommerce
/*
** Paste in functions.php
** Remove "Products" from Yoast SEO breadcrumbs in WooCommerce
*/
add_filter( 'wpseo_breadcrumb_links', function( $links ) {
// Check if we're on a WooCommerce page
// Checks if key 'ptarchive' is set
// Checks if 'product' is the value of the key 'ptarchive', in position 1 in the links array
if ( is_woocommerce() && isset( $links[1]['ptarchive'] ) && 'product' === $links[1]['ptarchive'] ) {
// True, remove 'Products' archive from breadcrumb links
unset( $links[1] );
}
// Rebase array keys
$links = array_values( $links );
// Return modified array
return $links;
});
@BenjaminLaschkar
Copy link

Work like a charm thanks

@janvanelst
Copy link

This code worked perfect for me! (I used Code Snippets to implement it as I'm a complete beginner). Thanks for sharing this.

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