Skip to content

Instantly share code, notes, and snippets.

@badsyntax
Last active August 26, 2020 09:28
Show Gist options
  • Save badsyntax/ad6e7df3f8ed408cfbd787def1ba83fb to your computer and use it in GitHub Desktop.
Save badsyntax/ad6e7df3f8ed408cfbd787def1ba83fb to your computer and use it in GitHub Desktop.
add_filter( 'woocommerce_get_breadcrumb', 'custom_breadcrumb', 10, 2 );
function custom_breadcrumb( $crumbs, $object_class ){
// Loop through all $crumb
foreach( $crumbs as $key => $crumb ){
$taxonomy = 'product_cat'; // The product category taxonomy
// Check if it is a product category term
$term_array = term_exists( $crumb[0], $taxonomy );
// if it is a product category term
if ( $term_array !== 0 && $term_array !== null ) {
// Get the WP_Term instance object
$term = get_term( $term_array['term_id'], $taxonomy );
// Category id
if ($term->term_id == 18) {
$pageId = 44;
$crumbs[$key][1] = get_permalink($pageId);
}
}
}
return $crumbs;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment