functions - How do I hide or remove 'Category' from wordpress breadcrumbs

admin2025-01-07  5

I'm building an ecommerce product page for a single product and am interested in including breadcrumbs. Since I only have a single product, how might I remove or hide the "Category" (currently labeled "Topicals") from the breadcrumb path:

Home > Topicals > Force of Nature - Mobility Balm

Here's a link to the page where this is visible.

/

Additionally, this page doesn't show up in my 'Pages' tab in my dashboard but is editable from my 'Templates' tab since I've built it as a Single Product template through Elementor. Why does this page not appear within the 'Pages' tab?

I'm pretty new to building websites (this being my first), I appreciate the patience. Thanks!

I'm building an ecommerce product page for a single product and am interested in including breadcrumbs. Since I only have a single product, how might I remove or hide the "Category" (currently labeled "Topicals") from the breadcrumb path:

Home > Topicals > Force of Nature - Mobility Balm

Here's a link to the page where this is visible.

https://zomatonics.com/product/mobility-balm/

Additionally, this page doesn't show up in my 'Pages' tab in my dashboard but is editable from my 'Templates' tab since I've built it as a Single Product template through Elementor. Why does this page not appear within the 'Pages' tab?

I'm pretty new to building websites (this being my first), I appreciate the patience. Thanks!

Share Improve this question edited Dec 21, 2020 at 22:17 Tus Henry asked Dec 21, 2020 at 22:08 Tus HenryTus Henry 112 bronze badges 1
  • Those breadcrumbs are generated by WooCommerce, not WordPress, I think. Check with WooCommerce's support streams. – Pat J Commented Dec 21, 2020 at 22:15
Add a comment  | 

1 Answer 1

Reset to default 0

Try:

add_filter( 'woocommerce_get_breadcrumb', 'cwpai_modify_woocommerce_breadcrumbs', 10, 2 );

function cwpai_modify_woocommerce_breadcrumbs( $crumbs, $breadcrumb_class ) {
    $new_crumbs = array();

    foreach ( $crumbs as $key => $crumb ) {
        // Keep the home link, parent categories, and product name
        if ( $key == 0 || $key == count($crumbs) - 2 || $key == count($crumbs) - 1 ) {
            $new_crumbs[] = $crumb;
        }
    }

    return $new_crumbs;
}
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736261392a738.html

最新回复(0)