Custom action not working in Woocommerce

Question

I’ve created a custom action in woocommerce in order to rewrite the breadcrumbs function and put it in another place into html, but it didn’t work.

Firstly, I removed the original Woocommerce breadcrumb:

remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0);

After, I added a custom action in my theme functions.php:

add_action('woo_breadcrumbs', 'woocommerce_breadcrumb', 20, 0);

And my custom function for breadcrumbs:

function woocommerce_breadcrumb( $args = array() ) {
    $defaults = apply_filters( 'woocommerce_breadcrumb_defaults', array(
        'delimiter'   => ' / ',
        'wrap_before' => '<nav class="woocommerce-breadcrumb" ' . ( is_single() ? 'itemprop="breadcrumb"' : '' ) . '>',
        'wrap_after'  => '</nav>',
        'before'      => '',
        'after'       => '',
        'home'        => _x( 'Home', 'breadcrumb', 'woocommerce' ),
    ) );
    $args = wp_parse_args( $args, $defaults );
    wc_get_template( 'global/breadcrumb.php', $args );
}

Finally, I put this on my header.php:

<?php do_action('woo_breadcrumbs'); ?>

I have no idea what could be wrong here. Any help??

0
joaogdesigner 4 years 2020-02-24T08:38:37-05:00 0 Answers 110 views 0

Leave an answer

Browse
Browse