Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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-x

    Thanks for your help!

    Best regards,
    CJGVD

    #1414076

    Hey 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,
    Mike

    #1414233

    Dear 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,
    CJGVD

    #1414440

    Hi,
    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,
    Mike

    #1414693

    Dear 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,
    CJGVD

    #1414766

    Hi,
    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:
    Enfold_Support_2706.jpeg
    Best regards,
    Mike

    #1415031

    Dear 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,
    CJGVD

    P.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

    #1415072

    Hi,
    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

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Breadcrumb is not showing the primary product category’ is closed to new replies.