How to Customize the WooCommerce breadcrumbs

Discussion in 'Tutorials' started by Khung Long, May 6, 2018.

  1. Khung Long

    Khung Long New Member

    Joined:
    May 6, 2018
    Messages:
    1
    Likes Received:
    0
    Notes: Insert to functions.php (Appereance --> Editor --> functions.php) or Using plugin Code Snippets (https://wordpress.org/plugins/code-snippets/)
    ---
    1. If you want to change the home text.
    /**
    * Rename "home" in breadcrumb
    */
    add_filter( 'woocommerce_breadcrumb_defaults', 'wcc_change_breadcrumb_home_text' );
    function wcc_change_breadcrumb_home_text( $defaults ) {
    // Change the breadcrumb home text from 'Home' to 'Apartment'
    $defaults['home'] = 'Apartment';
    return $defaults;
    }

    2. If you want to change the breadcrumb separator.

    /**
    * Change the breadcrumb separator
    */
    add_filter( 'woocommerce_breadcrumb_defaults', 'wcc_change_breadcrumb_delimiter' );
    function wcc_change_breadcrumb_delimiter( $defaults ) {
    // Change the breadcrumb delimeter from '/' to '>'
    $defaults['delimiter'] = ' > ';
    return $defaults;
    }

    3. Change the home link to a different URL

    /**
    * Replace the home link URL
    */
    add_filter( 'woocommerce_breadcrumb_home_url', 'woo_custom_breadrumb_home_url' );
    function woo_custom_breadrumb_home_url() {
    return 'http://woocommerce.com';
    }

    4. Remove the breadcrumbs

    /**
    * Remove the breadcrumbs
    */
    add_action( 'init', 'woo_remove_wc_breadcrumbs' );
    function woo_remove_wc_breadcrumbs() {
    remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
    }
     

Share This Page