-
Hello, I had the exact same problem as this person in this thread:
https://support.rankmath.com/ticket/woocommerce-breadcrumb-bug/Like him, some of my products have multiple categories, so I selected a “primary category”, so the breadcrumb will show “shop > primary category” instead of “shop > alphabetically first category”.
The product section under Rank Math Titles & Meta still displays only “none”, “product categories”, and “product tags” beside the Primary Taxonomy field; I have chosen “Product Categories” since Primary Category is still not an option.
The breadcrumb ux element is currently the woocommerce one and I tried copying the code like Todd did in that other ticket. My functions.php now looks like this:if (function_exists('rank_math_the_breadcrumbs')) rank_math_the_breadcrumbs(); add_filter( 'rank_math/frontend/breadcrumb/main_term', function( $current_term, $terms ) { if ( function_exists( 'is_product' ) && is_product() ) { global $post; $terms = get_the_terms( $post, 'product_cat' ); if ( ! empty( $terms ) ) { return $terms[0]; } } return $current_term; }, 10, 2 );
I was hoping doing this would override the woocommerce breadcrumb and show my primary category but it didn’t work. When I inspect the product page, the breadcrumb is under
<div class=”product-breadcrumb-container is-normal”><nav class=”woocommerce-breadcrumb breadcrumbs>So it is still using the woocommerce breadcrumb and not the rank math one.
Could you please advise what I need to change, and where, to make this menu element show my Primary Category instead of Alphabetically First Category.Thank you
The ticket ‘Overriding Woocommerce breadcrumbs with Rank Math instead?’ is closed to new replies.