Skip to content

Instantly share code, notes, and snippets.

@dan-zakirov
Created March 14, 2024 20:56
Show Gist options
  • Save dan-zakirov/fc76dff87d19aadcb333dc94a6fcbea7 to your computer and use it in GitHub Desktop.
Save dan-zakirov/fc76dff87d19aadcb333dc94a6fcbea7 to your computer and use it in GitHub Desktop.
add_filter('rank_math/frontend/breadcrumb/items', function ($crumbs, $Breadcrumb) {
$shop_page_id = wc_get_page_id('shop'); //Get the shop page ID
if (is_product_category() || is_product() || is_cart() || is_checkout()) {
$new_breadcrumb = [
_x('Каталог товаров', 'breadcrumb', 'woocommerce'), //Title
get_permalink(wc_get_page_id('shop')) // URL
];
array_splice($crumbs, 1, 0, [$new_breadcrumb]); //Insert a new breadcrumb after the 'Home' crumb
}
return $crumbs;
}, 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment