Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thomasfromwood/2d5083dc9635dd9a2a9b0ffcddbc2af1 to your computer and use it in GitHub Desktop.
Save thomasfromwood/2d5083dc9635dd9a2a9b0ffcddbc2af1 to your computer and use it in GitHub Desktop.
Example of how to customize the Yoast SEO breadcrumbs #yoast #plugin #wordpress
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/*
* Add shop link to the Yoast SEO breadcrumbs for a WooCommerce shop page.
* Credit: https://wordpress.stackexchange.com/users/8495/rjb
* Last Tested: Apr 20 2017 using Yoast SEO 4.6 on WordPress 4.7.3
*/
add_filter( 'wpseo_breadcrumb_links', 'wpseo_breadcrumb_add_woo_shop_link' );
function wpseo_breadcrumb_add_woo_shop_link( $links ) {
global $post;
if ( is_woocommerce() ) {
$breadcrumb[] = array(
'url' => get_permalink( woocommerce_get_page_id( 'shop' ) ),
'text' => 'Shop',
);
array_splice( $links, 1, -2, $breadcrumb );
}
return $links;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment