Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author John Havlik

    (@mtekk)

    I’m looking at this on my testbed, it appears that “Attribute” is actually a separate taxonomy. Breadcrumb NavXT doesn’t exactly support taxonomy jumping at the moment. However, I’ll keep playing around with this and will report back with my results.

    Thread Starter taimerlan

    (@taimerlan)

    Hi John. Thanks for reply.

    <?php
    if ( ! defined( 'ABSPATH' ) ) {
        exit;
    }
    
    global $post;
    
    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( $crumb[1] ) . '">' . esc_html( $crumb[0] ) . '</a>';
            } else {
    
    // check that we are on the product page
                if ( is_singular('product') ) {
    // get the attribute
                    $post_brand = wc_get_product_terms( $post->ID, 'pa_brand', array( 'fields' => 'all' ) );
                    if ($post_brand) {
    // get the attribute object
                        $post_brand = $post_brand[0];
    // get the previous link in crumbs
                        $bread_prev = array_slice($breadcrumb, -2, 1);
    // add name and link to the brand
                        echo '<a href="' . esc_url( $bread_prev[0][1] ) . '/?pa_brand=' . $post_brand->slug .'">' . esc_html( $bread_prev[0][0] ) . ' ' . $post_brand->name . '</a>';
                        echo $delimiter;
                    }
                }
    
                echo esc_html( $crumb[0] );
            }
    
            echo $after;
    
            if ( sizeof( $breadcrumb ) !== $key + 1 ) {
                echo $delimiter;
            }
        }
    
        echo $wrap_after;
    
    }

    That’s what I managed to get with standard woocommerce breadcrumbs.
    Perhaps this will help you.
    Best regards,
    Artem

    • This reply was modified 6 years, 1 month ago by taimerlan.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Category with attribute (like brand) in Breadcrumb’ is closed to new replies.