Last active
August 26, 2020 09:28
-
-
Save badsyntax/ad6e7df3f8ed408cfbd787def1ba83fb to your computer and use it in GitHub Desktop.
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
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