I found the code what can help me to add a category to the breadcrumbs woocommerce product page.
Here it is:
function product_cat_breadcrumbs($post, $return = false) { $taxonomy_name = 'product_cat'; $terms = get_the_terms($post->ID, $taxonomy_name); $term_count = 0; foreach ($terms as $term) { $term_count++; global $bcn_admin; if ($bcn_admin !== null) { // Load options $bcn_admin->breadcrumb_trail->opt = wp_parse_args(get_option('bcn_options'), $bcn_admin->breadcrumb_trail->opt); $bcn_admin->breadcrumb_trail->term_parents($term->term_id, $taxonomy_name); return $bcn_admin->breadcrumb_trail->display($return); } break; } // If we didn't find any terms, fallback to default behaviour. if ($term_count == 0) return bcn_display($return); }
I added it to the functions.php how it was suggested, but nothing happens. May be you can help me to figur out, how I can make the category be visiable in the product page?
Unfortunately we don\'t have a quick fix to add the category the woocommerce breadcrumbs.
But you could edit the single-product.php and call the category directly to the breadcrumbs since for the single page we are not using the automatically generated breadcrumbs.
Do not hesitate to contact us if you have other questions.
We tried to add this code but it is not working, the product page will not load, can you provide more info on where exactly this code should go, we need to show product category before the product name.
Hi!
I found the code what can help me to add a category to the breadcrumbs woocommerce product page.
Here it is:
function product_cat_breadcrumbs($post, $return = false) {
$taxonomy_name = 'product_cat';
$terms = get_the_terms($post->ID, $taxonomy_name);
$term_count = 0;
foreach ($terms as $term) {
$term_count++;
global $bcn_admin;
if ($bcn_admin !== null) {
// Load options
$bcn_admin->breadcrumb_trail->opt = wp_parse_args(get_option('bcn_options'), $bcn_admin->breadcrumb_trail->opt);
$bcn_admin->breadcrumb_trail->term_parents($term->term_id, $taxonomy_name);
return $bcn_admin->breadcrumb_trail->display($return);
}
break;
}
// If we didn't find any terms, fallback to default behaviour.
if ($term_count == 0)
return bcn_display($return);
}
I added it to the functions.php how it was suggested, but nothing happens. May be you can help me to figur out, how I can make the category be visiable in the product page?
Hello,
Would you want to use the category to the single item page? or default product page?
Regards
---------------------
Hosting we recommend ( Free SSL and CDN included in all plan ).
Speed up your site with Autoptimize
Test your site with GTmetrix and fix the issue to make it faster
How to Update your Theme
Hello,
Unfortunately we don\'t have a quick fix to add the category the woocommerce breadcrumbs.
But you could edit the single-product.php and call the category directly to the breadcrumbs since for the single page we are not using the automatically generated breadcrumbs.
Do not hesitate to contact us if you have other questions.
Regards
---------------------
Hosting we recommend ( Free SSL and CDN included in all plan ).
Speed up your site with Autoptimize
Test your site with GTmetrix and fix the issue to make it faster
How to Update your Theme
oh, but how I can call it?
To call the category you can use this code :
Do not hesitate to contact us if you have other questions.
Regards
---------------------
Hosting we recommend ( Free SSL and CDN included in all plan ).
Speed up your site with Autoptimize
Test your site with GTmetrix and fix the issue to make it faster
How to Update your Theme
This is a useful code. Thanks. But could you update the code to get the sub category?
Hello,
We tried to add this code but it is not working, the product page will not load, can you provide more info on where exactly this code should go, we need to show product category before the product name.
thanks
Hello Yazan,
I am sorry but please create a new ticket.
Thanks in advance.
Regards
---------------------
Hosting we recommend ( Free SSL and CDN included in all plan ).
Speed up your site with Autoptimize
Test your site with GTmetrix and fix the issue to make it faster
How to Update your Theme