Remove Store from BreadCrumb in WooCommerce

How to remove Store Text from Breadcrumbs in a woo trade? [Home → Shop → Pink Himalayan Salt] I want to set the bread crumbs according to my navigation menu on the WordPress site. [Home → Products → Salt → Himalayan Pink Salt] I used some pages, user links, categories and products in my main menu.

See screenshot.

Bredcrumb - enter image description here


Menu - https://www.screencast.com/t/To2xchRWJo

+4
source share
3 answers

You can override WooCommerce templates using a theme (read the following white paper):

+

plugins/woocommerce/templates/global/breadcrumb.php
to: themes/yourtheme/woocommerce/global/breadcrumb.php, , :

<?php
/**
 * Shop breadcrumb
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/global/breadcrumb.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @see         https://docs.woocommerce.com/document/template-structure/
 * @author      WooThemes
 * @package     WooCommerce/Templates
 * @version     2.3.0
 * @see         woocommerce_breadcrumb()
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

if ( ! empty( $breadcrumb ) ) {

    $breadcrumb0 = $breadcrumb[0];
    $shop_txt = __( 'Shop', 'woocommerce' );
    $products_txt = __( 'Products', 'woocommerce' );
    $products_url = home_url( '/products/' );
    $breadcrumb10 = array( $products_txt );
    $breadcrumb11 = array( $products_txt, $products_url );
    if(is_product() || is_shop() || is_product_category() || is_product_tag() ){
        if( $breadcrumb[1][0] == $shop_txt ){
            if( ! empty( $breadcrumb[1][1] ) )
                $breadcrumb[1] = $breadcrumb11;
            else
                $breadcrumb[1] = $breadcrumb10;
        } else {
            unset($breadcrumb[0]);
            array_unshift($breadcrumb, $breadcrumb0, $breadcrumb11);
        }
    }

    echo $wrap_before;

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

        echo $before;

        if ( ! empty( $crumb[1] ) && sizeof( $breadcrumb ) !== $key + 1 ) {
            echo '<a href="' . esc_url( $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;

}

:

  • "" ""
  • "" "", "" .

, breadcrumps : Home > Products , ...

+1

CSS, , . :

CSS

ul.breadcrumbs li:nth-of-type(2) {display:none}

, ! important

ul.breadcrumbs li:nth-of-type(2) {display:none!important}

, . . CSS.

0

I have an answer by making changes to functions.php https://www.screencast.com/t/U42lqPduY707

if (get_post_type() ==  'product')
{
echo sprintf($link, '#', esc_html__('Products', 'thegem'));
//echo sprintf($link, get_permalink(get_option ('woocommerce_shop_page_id' , 0 )), esc_html__('Product', 'thegem'));
$taxonomy = 'product_cat';
$terms = get_the_terms( $post->ID, $taxonomy );
foreach ( $terms as $c ) {
$c->term_id;
//  echo '<a href="' . get_term_link($c, 'product_cat') . '">' . ($c->name ) . '</a>';
if($c->term_id=='36') {
echo $delimiter;
echo sprintf($link, get_permalink( 106 ), esc_html__($c->name, 'thegem'));
}
}
}
else {
$slug = $post_type->rewrite;
printf($link, $home_link . '/' . $slug['slug'] . '/', $post_type->labels->singular_name);
}
0
source

Source: https://habr.com/ru/post/1685015/


All Articles