Product Search Results Breadcrumbs

Is there anyway to add the SHOP breadcrumb to the product search results?

https://usatcorp.com/?s=IBR900&post_type=product

When using the product search widget in my PRO header, it ignores that we’re shopping in the store.
I’d like them to be able to return to the main shop easily with a breadcrumb if possible.

Hi Jesse,

Thanks for reaching out.

Since the breadcrumbs in the theme is only applicable to built-in post types of Wordpresa and theme itself, then you’ll have to create a custom code to include other linking to the breadcrumbs. Please check this as a sample

The indexes such as [0], [1], and so on represent the breadcrumb items. And you’ll have to change is_page() as condition with is_search() with post type. Example

function product_search_breadcrumbs( $crumbs, $args ) {

global $wp_query;
$wp_query->query_vars['post_type'];
if ( is_search() && $wp_query->query_vars['post_type'] == 'product') {

   $crumbs[0]['label'] = 'Shop';
    $crumbs[0]['url'] = '//example.com/shop/';

}
	return $crumbs;
}
add_filter( 'x_breadcrumbs_data', 'product_search_breadcrumbs', 10, 999999 );

That’s just a sample and idea, but we don’t provide support to any custom code nor maintain it. You can modify it according to your preference.

Thanks!

BRILLIANT, that works perfectly.
Thank you!

You’re welcome!
We’re glad @Rad were able to help you out.

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