Breadcrumbs shortcode issue w/ products

Hello there,

We added the Breadcrumbs element as a global block which we then added to our products page via the following code:

function woocommerce_template_breadcrumbs() {
	echo do_shortcode('[cs_gb id=19286]');

For some unknown reason the breadcrumbs won’t display the products category as intermediary pages. The list goes straight from Home to the Shop page to the Product page.

I have added the URL to view the output as a secure note.

Would appreciate your feedback!

Thank you

Hi There,

To add the product categories to breadscrumb, you have to setup a child theme first:

After that add this custom code under functions.php file locates in your child theme:

add_filter('x_breadcrumbs_data', 'post_parent_trail', 9999999, 2);
function post_parent_trail ($crumbs, $args) {
	if ( is_singular('product') ) {
		global $post;
		$category = get_the_terms( $post->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;  

Hope that helps and thank you for understanding.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.