Skip to content

Instantly share code, notes, and snippets.

@davevanhoorn
Created August 3, 2018 05:10
Show Gist options
  • 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;
});
@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