Hello,
We apologize for the issue you are facing with including the shop page in your breadcrumbs. By default, Rank Math does not automatically include the WooCommerce shop page in the breadcrumb trail for product categories. However, you can achieve this by adding a custom code snippet to your theme’s functions.php file.
Here’s a code snippet that you can use to include the shop page in your breadcrumbs:
// Fixes missing "Shop" breadcrumb in WPML translated store pages.
if( function_exists( 'icl_object_id' ) ) {
add_filter( 'rank_math/frontend/breadcrumb/items', 'wpmlsupp_8672_fix_wc_store_breadcrumbs', 10, 2 );
}
function wpmlsupp_8672_fix_wc_store_breadcrumbs( $crumbs, $class ) {
if ( is_product() || is_product_category() || is_product_tag() ){
$current_language = apply_filters( 'wpml_current_language', NULL );
$default_language = apply_filters( 'wpml_default_language', NULL );
if ($current_language !== $default_language) {
$shop_page_id = wc_get_page_id( 'shop' );
$shop_page = get_post( $shop_page_id );
$store_crumb = array (
'0' => get_the_title( $shop_page ),
'1' => get_permalink( $shop_page ),
'hide_in_schema' => ""
);
array_splice( $crumbs, 1, 0, array( $store_crumb ) );
}
}
return $crumbs;
}
This code checks if you are on a product or product category page and adds the shop page to the breadcrumb trail. Please ensure to take a backup of your website before making any changes to the code.
If you have any further questions or need assistance with this implementation, please reply to this ticket, and a human agent from our support team will be happy to help you further!
Thank you for raising this concern!
Sources:
Multilingual SEO with Rank Math SEO & WPML » Rank Math
This is an automated reply from Rank Math Support Bot. If you need further assistance, please reply to this topic and a human support agent will reply to you shortly.
Hello,
Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.
If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.
Thank you.