Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Nikschavan/f625ae2afa770b04c940de932a8becbc to your computer and use it in GitHub Desktop.
Save Nikschavan/f625ae2afa770b04c940de932a8becbc to your computer and use it in GitHub Desktop.

Revisions

  1. Nikschavan revised this gist Feb 10, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion woocommerce-remove-uncategorized-from-breadcrumb.php
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    * @return Array WooCommerce Breadcrumb crumbs with default category removed.
    */
    function your_prefix_wc_remove_uncategorized_from_breadcrumb( $crumbs ) {
    $category = get_option( 'default_product_cat' );
    $category = get_option( 'default_product_cat' );
    $caregory_link = get_category_link( $category );

    foreach ( $crumbs as $key => $crumb ) {
  2. Nikschavan revised this gist Feb 10, 2018. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions woocommerce-remove-uncategorized-from-breadcrumb.php
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,12 @@
    <?php // don't copy this line in your code.

    /**
    * Remove uncategorized from the WooCommerce breadcrumb.
    *
    * @param Array $crumbs Breadcrumb crumbs for WooCommerce breadcrumb.
    * @return Array WooCommerce Breadcrumb crumbs with default category removed.
    */
    function your_prefix_wc_remove_uncategorized_from_breadcrumb( $crumbs ) {
    $category = get_option( 'default_product_cat' );
    $category = get_option( 'default_product_cat' );
    $caregory_link = get_category_link( $category );

    foreach ( $crumbs as $key => $crumb ) {
    @@ -16,7 +15,7 @@ function your_prefix_wc_remove_uncategorized_from_breadcrumb( $crumbs ) {
    }
    }

    return $crumbs;
    return array_values( $crumbs );
    }

    add_filter( 'woocommerce_get_breadcrumb', 'your_prefix_wc_remove_uncategorized_from_breadcrumb' );
  3. Nikschavan revised this gist Feb 10, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion woocommerce-remove-uncategorized-from-breadcrumb.php
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    <?php // don't copy this file in your code.
    <?php // don't copy this line in your code.

    /**
    * Remove uncategorized from the WooCommerce breadcrumb.
  4. Nikschavan revised this gist Feb 10, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion woocommerce-remove-uncategorized-from-breadcrumb.php
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@
    * @return Array WooCommerce Breadcrumb crumbs with default category removed.
    */
    function your_prefix_wc_remove_uncategorized_from_breadcrumb( $crumbs ) {
    $category = get_option( 'default_product_cat' );
    $category = get_option( 'default_product_cat' );
    $caregory_link = get_category_link( $category );

    foreach ( $crumbs as $key => $crumb ) {
  5. Nikschavan created this gist Feb 10, 2018.
    22 changes: 22 additions & 0 deletions woocommerce-remove-uncategorized-from-breadcrumb.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    <?php // don't copy this file in your code.

    /**
    * Remove uncategorized from the WooCommerce breadcrumb.
    *
    * @param Array $crumbs Breadcrumb crumbs for WooCommerce breadcrumb.
    * @return Array WooCommerce Breadcrumb crumbs with default category removed.
    */
    function your_prefix_wc_remove_uncategorized_from_breadcrumb( $crumbs ) {
    $category = get_option( 'default_product_cat' );
    $caregory_link = get_category_link( $category );

    foreach ( $crumbs as $key => $crumb ) {
    if ( in_array( $caregory_link, $crumb ) ) {
    unset( $crumbs[ $key ] );
    }
    }

    return $crumbs;
    }

    add_filter( 'woocommerce_get_breadcrumb', 'your_prefix_wc_remove_uncategorized_from_breadcrumb' );