Sub-header landmark question

Hello!

I’m not sure how to ask this question properly but I’ll do my best.
My website is: https://crisisequipped.com

When you go to my shop page (https://crisisequipped.com/shop), you’re able to choose many products based on categories.

For this question I’ll use an example using the “Water Systems” category. After I click on there, I can choose from subcategories, so in this case I chose “Storage Tanks”. This is what appears right below the header:

When I choose one of the products under the “Storage Tanks” subcategory, this is what happens:

As you can see, “Water Systems” and “Storage Tanks” disappear. This happens with all my products.

Is there a way to get it to show up as Shop > Water Systems > Storage Tanks > Stackable Water tank… (or whichever other product is chosen) ?

I hope my question made sense :slight_smile:
Thank you for your help!

Hey Nadia,

Thanks for writing in!

To get this exact breadcrumbs structure (Home > Blog Page Home/Shop > Category > Post/Product), please add this code snippet in the functions.php file of the child theme directory:

add_filter('x_breadcrumbs_data', 'post_parent_trail', 9999999, 2);

	function post_parent_trail ($crumbs, $args) {
		if ( array( 'post', 'product' ) ) {

			$category = get_the_category( get_the_ID() );

				if ( count( $category ) > 0 ) {

					$cat_array = array();
					$cat_array[1]['label'] = $category[0]->name;
					$cat_array[1]['url'] = get_category_link( $category[0]->term_id );

					array_splice($crumbs, 2, 0, $cat_array);
				}
		}
	return $crumbs;  
}

We would loved to know if this has work for you. Thank you.

It didn’t work :slightly_frowning_face:
I cleared my cache just to double check and opened it on a different browser, but it’s hasn’t changed.

Is there a different code I can try?
Thank you :slight_smile:

We’re sorry for the confusion, Nadia. The reason why there is no trail back to the category is because you can assign multiple categories to a product and there are several possible outcomes that you will need to consider. Below are some possibilities.

  • Display all categories in the breadcrumbs
  • Display only 1 random category

This also will get complicated if you have parent categories.

We love to help out but regretfully, this is not as simple as it looks like and this requires custom work which is outside the scope of our support.

What I will do instead is post your concern as feature request. This way, our development team will know if other users will be interested in this feature and they will be the one to decide if they will build a feature for this or provide us with the correct snippet that will cover at least one of the scenarios I’ve listed.

Thank you for understanding.

Ok no problem :slight_smile:
Thank you so much anyway!

You are most welcome. :slight_smile:

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