Remove All Product Categories From Breadcrumbs by Rank Math!
Table of Contents
Introduction
Rank Math is a popular WordPress SEO plugin that offers a variety of functions to help your website rank higher in search engines. One of its advantages is the ability to show breadcrumbs on your website. A navigation tool called Breadcrumbs shows a user where they are on your website and makes it simple for them to return to earlier pages. Product categories are automatically added by Rank Math to the breadcrumbs of product pages, but you might occasionally want to do away with them. The following tutorial is going to show how you can remove all product categories from the breadcrumbs of Rank Math with a filter/code snippet and without using code.
Filter to Remove Product Categories from Rank Math Breadcrumbs
add_filter('rank_math/frontend/breadcrumb/items', function ($crumbs, $class) { if ( is_product() ) { global $product; $categories = get_the_terms( $product->ID, 'product_cat' ); foreach($categories as $category){ $category = $category->name; $key = array_search($category, array_column($crumbs, '0'), true); if (isset($key) && ($key != false ) ) { unset($crumbs[$key]); $crumbs = array_values($crumbs); } } } return $crumbs; }, 10, 2);
Expected Output:
Home / Product Name
How to add filters or Hooks to your WordPress site
I know still some of us get confused about where and how we should add filters or hooks to our WordPress site. For Rank Math, I’d recommend the Knowledge base article that Rank Math published: How to Add a Filter/Hook to Your Website?
Remove Product Categories in breadcrumbs from the settings
Head over to WordPress Dashboard > Rank Math > Titles & Meta > Products > Primary Taxonomy and choose None as Primary Taxonomy there to remove all your product categories from breadcrumbs

Yes, it’s that simple. Now you may decide whether you need to apply the filter or remove the categories completely from the settings.
Conclusion
It’s easy to remove product categories from Rank Math breadcrumbs by adding a small piece of code to your website. You can modify the Rank Math breadcrumbs to meet the requirements of your website by using this snippet of code. Prior to making any changes to your code, always make a backup of your website. And, don’t forget to clear your site cache if the changes are not being reflected on your site somehow.
I hope that was helpful. Thanks for your support!
Categories: WordPress, Rank Math, WordPress SEO
Feel free to ask anything regarding the filter in the comment below!