![Check out Enfold](https://kriesi.at/wp-content/themes/kriesi/images/banner-enfold.jpg)
-
AuthorPosts
-
July 20, 2023 at 1:58 pm #1413833
Dear Kriesi-Team,
I have activated the breadcrumb navigation on my product pages. However, if my products fall into more than one category, the breadcrumb is showing the last category (in chronological order) regardless of which category is set to be the primary category. What can I do to change that, so that the breadcrumb is showing the primary category?
For example:
Product X belongs to categories A, B and C. Category B is set to be the primary category.
The breadcrumb looks like this:
…/shop/category-c/product-x
But it should be:
…/shop/category-b/product-xThanks for your help!
Best regards,
CJGVDJuly 22, 2023 at 9:14 pm #1414076Hey CJGVD,
Thank you for your patience, how did you set a primary category I only see the option to set a parent category.Best regards,
MikeJuly 24, 2023 at 3:02 pm #1414233Dear Mike,
thanks for your question. I can set the primary category when creating or editing the product in the right-hand panel menu of the product page under Categories.
Because of your question I googled a bit and found out, that setting this primary category is not a default function of WooCommerce. I guess, it comes with Yoast SEO, which is used on this website. Then the options under Categories look like in the screenshot in this article: https://tool-pilot.de/tutorials/wordpress-primaere-kategorie-festlegen/. In Yoast SEO I checked the breadcrumbs settings for product categories and they seem OK. So I’m clueless to what is wrong or missing that it does not work correctly.
Besides, I found this article in the Internet, which suggests to use extra code in functions.php to repair the “faulty behaviour” of WooCommerce breadcrumbs: https://www.udo-telaar.de/woocommerce-breadcrumb-reparieren/.
I would be glad to hear your opinion on all this. Thanks a lot for diving in with me. :-)
Best regards,
CJGVDJuly 26, 2023 at 12:05 am #1414440Hi,
I didn’t realize that you were refuring to a Yoast category customization, have you tried using the Yoast breadcrumb?
If using the Yoast breadcrumb shortcode works correctly then use this solution to use it instead of the theme breadcrumb.Best regards,
MikeJuly 27, 2023 at 4:46 pm #1414693Dear Mike,
thanks for your reply!
At first I also did not know that this primary category was added by Yoast SEO and not by WordPress, WooCommerce or Enfold. The settings for the Yoast SEO breadcrumbs are set and in my opinion OK. However, still the Enfold (?) breadcrumb is shown. I have used your code (“then use this solution”) in functions.php, cleared the cache, but still the wrong breadcrumb is showing. I think because your code refers to posts and my issue refers to the products in WooCommerce. Could you please alter the code for making it work for products? I have created a login for you, see private content.
Best regards,
CJGVDJuly 28, 2023 at 6:06 pm #1414766Hi,
Thanks for the login, you were right that the function I linked to was for blog posts instead of woo products, I adjusted the script so now the Yoast breadcrumbs show on the single product pages instead of the theme breadcrumbs:function add_yoast_breadcrumbs_shortcode_to_single_product_title_container() { ?> <script> (function($){ var wpseo_breadcrumb = '<span id="breadcrumbs" class="breadcrumb"><?php echo do_shortcode("[wpseo_breadcrumb]"); ?></span>'; $('#top.single-product').each(function () { $(wpseo_breadcrumb).appendTo('.title_container .container'); $(this).find('.avia-breadcrumbs').css('display','none'); }); })(jQuery); </script> <?php } add_action('wp_footer', 'add_yoast_breadcrumbs_shortcode_to_single_product_title_container');
unfortunately the breadcrumbs are not showing as you wish, try adjusting the Yoast breadcrumb options to show the order that you wanted.
Also I found a javascript function in your child theme stylesheet that should be in your child theme functions.php so I moved it for you:
Best regards,
MikeJuly 31, 2023 at 1:29 pm #1415031Dear Mike,
thanks a lot for the modified code for showing the Yoast breadcrumbs instead of the theme ones.
I thought the settings in Yoast were complete before, but I noticed now that not only the “Breadcrumbs für Taxonomies” should be set, but also the “Breadcrumbs für Inhaltstypen” (since here is also a category “Produkte” which need to be set to “Produkt-Kategorien”). Now everything is working fine.
Thanks again! You can close this thread now.
Best regards,
CJGVDP.S. Also thanks a lot for adding the php-code from the style.css into the functions.php. No wonder it did not work. :-P
July 31, 2023 at 6:01 pm #1415072Hi,
Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.Best regards,
Mike -
AuthorPosts
- The topic ‘Breadcrumb is not showing the primary product category’ is closed to new replies.