Hi.
I found this code here to add a trail of breadcrumbs on my page.
add_filter('x_breadcrumbs_data', 'post_parent_trail', 9999999, 2);
function post_parent_trail ($crumbs, $args) {
if ( is_singular('product') ) {
global $product;
$category = get_the_terms( $product->ID, 'product_cat' );
if ( count( $category ) > 0 ) {
$cat_array = array();
$cat_array[1]['label'] = $category[0]->name;
$cat_array[1]['url'] = get_term_link( $category[0]->term_id );
array_splice($crumbs, 2, 0, $cat_array);
}
}
return $crumbs;
}
Its showing for example Home > Shop > Wall Art > product name.
However, the product is under a sub-category of Wall Art, which is “Posters”. Any possibility to tweak the code to show:
Home > Shop > Wall Art > Posters > product code ?
Thank you.