Created
May 10, 2017 04:50
-
-
Save cinghaman/30a9889ccbdbd59a111cd4714081cf1f to your computer and use it in GitHub Desktop.
Modifying WooCommerce Breadcrumbs structure to show home/shop-page/product-name
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
/** | |
* 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