Skip to content

Instantly share code, notes, and snippets.

@cinghaman
Created May 10, 2017 04:50
Show Gist options
  • Save cinghaman/30a9889ccbdbd59a111cd4714081cf1f to your computer and use it in GitHub Desktop.
Save cinghaman/30a9889ccbdbd59a111cd4714081cf1f to your computer and use it in GitHub Desktop.
Modifying WooCommerce Breadcrumbs structure to show home/shop-page/product-name
/**
* Update Breadcrumbs structure
*
*/
/* This function will go inside your child functions.php file of your theme */
function pf_custom_crumbs( $crumbs ) {
$newcrumbs = array();
// first crumb is the home
$newcrumbs[] = $crumbs[0];
// Now insert the shop
$newcrumbs[] = array( 'shop', get_permalink( woocommerce_get_page_id( 'shop' ) ) );
// Now insert the last crumb (i.e., the product)
$newcrumbs[] = $crumbs[sizeof($crumbs)-1];
return $newcrumbs;
}
add_filter('woocommerce_get_breadcrumb', 'pf_custom_crumbs');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment