Created
November 13, 2018 08:21
-
-
Save mklasen/5fe5b31c6a0171fffc06615dd295d5c1 to your computer and use it in GitHub Desktop.
Remove /products/ slug from Yoast Breadcrumb in Woocommerce Product Page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_filter( 'wpseo_breadcrumb_links', function($items) { | |
| // Remove second array item | |
| if( is_product() ) { | |
| unset( $items[1] ); | |
| } | |
| // Sort array | |
| ksort($items); | |
| // Return array with new values, preventing Yoast SEO to see double last links. | |
| return array_values($items); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment