Z
Z
zx5zx62021-01-29 21:43:54
WordPress
zx5zx6, 2021-01-29 21:43:54

How to remove breadcrumb element in Wordpress+Woocommerce+Astra?

In the online store on the WP+Woocommerce+Astra theme, on the product page, breadcrumbs are generated indicating the path from the main page to the current category or product page.
6014572ba71e3463623806.png

How to cut a link to the main page from this path and make the crumbs start from the product catalog page (from the second paragraph)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
istan302, 2021-02-08
@zx5zx6

The template responsible for the HK array is located in the plugin folder: "\wp-content\plugins\woocommerce\templates\global\breadcrumb.php"
acc. with documentation, you can copy it to your theme folder:
\OurTheme\woocommerce\global\breadcrumb.php
And then, edit as you like, it's pretty simple. In the example below, we "cut" the link to product-category

if ( ! empty( $breadcrumb ) ) {

  echo $wrap_before;

  foreach ( $breadcrumb as $key => $crumb ) {

    echo $before;

    if ( ! empty( $crumb[1] ) && sizeof( $breadcrumb ) !== $key + 1 ) {
      echo '<a href="' . esc_url( str_replace('product-category/','', $crumb[1]) ) . '">' . esc_html( $crumb[0] ) . '</a>';
    } else {
      echo esc_html( $crumb[0] );
    }

    echo $after;

    if ( sizeof( $breadcrumb ) !== $key + 1 ) {
      echo $delimiter;
    }
  }

  echo $wrap_after;

}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question