WooCommerce adds breadcrumbs by default to your single product pages, category archives, and other shop related pages. Breadcrumbs can be useful for users to navigate your site, but in some cases, you may want to remove them to simplify the design or layout of your site.
To remove the WooCommerce breadcrumbs, you can use the woocommerce_before_main_content
action hook and the remove_action
function. Here’s an example code snippet:
function wpsnippets_remove_woocommerce_breadcrumbs() {
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
}
add_action( 'init', 'wpsnippets_remove_woocommerce_breadcrumbs' );
In this code snippet, we define a function wpsnippets_remove_woocommerce_breadcrumbs
that uses the remove_action
function to remove the woocommerce_breadcrumb
function from the woocommerce_before_main_content
action hook. We hook this function to the init
action, which ensures that it is loaded early enough to remove the breadcrumbs before they are displayed.
You can modify the priority of the remove_action
function to ensure that the breadcrumbs are removed at the appropriate time, and you can use similar code to remove other elements from the WooCommerce shop pages.