Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #1001670

    janih
    Participant

    HI,

    Oh, sorry for confusion. However, I have an active child theme. At least it says so in Appearance settings: “Active: X – Child Theme”

    #1002167

    Jade
    Moderator

    Hi Janih,

    Kindly post a new thread and provide us with the following details so that we could check this further:

    – Link to your site
    – WordPress Admin username / password
    – FTP credentials

    Don’t forget to select Set as private reply. This ensures your information is only visible to our staff.

    #1076246

    adamzinger
    Participant

    Hi Christopher,

    I used the code from your post (https://community.theme.co/forums/topic/how-to-feature-product-category-in-breadcrumbs/page/2/#post-764836) and it almost works. It seems like it doesn’t give me a complete breadcrumb that includes all sub categories. For example…

    http://website.com/shop/category/ produces ‘home > shop > category’ which is right

    http://website.com/shop/category/sub-category/ produces ‘home > shop > sub category’ which is wrong as it misses out the parent category.

    I will the breadcrumb to go deeper than above examples so can you help?

    Many thanks,
    Adam

    #1077145

    Rad
    Moderator

    Hi there,

    The code only displays one category at a time. It needs more complex coding in order to display nested categories. A product can have multiple categories times the amount of child they have. Unfortunately, we can’t provide further customization. I tried it, but become more complex. You may also try 3rd party breadcrumbs that support woocommerce, you can simply replace the code with another code.

    Eg.

     if ( $v = get_breadcrumb_category('product_cat') ) {
               $product_category = get_3rd_party_breadcrumb();
             } else {
               $product_category = '';
             }

    Thanks!

    #1144618

    marcooos
    Participant

    +1 vote for proper breadcrumbs feature πŸ™‚

    #1144927

    Joao
    Moderator

    Thanks for your input!

    Your vote has been counted.

    Joao

    #1216478

    Wonderfully Made
    Participant

    I’ll also “vote” for breadcrumbs to work correctly properly for multi-level categories. Until then, this works for the category archive page and for single ‘post’ (ie. the ‘post’ type) pages only; rtl is untested, but probably works (copy get_breadcrumb_category() from earlier example):

    
    function x_breadcrumbs() {
    
        if ( x_get_option( 'x_breadcrumb_display', '1' ) ) {
    
          GLOBAL $post;
    
          $is_ltr         = ! is_rtl();
          $stack          = x_get_stack();
          $delimiter      = x_get_breadcrumb_delimiter();
          $home_text      = x_get_breadcrumb_home_text();
          $home_link      = home_url();
          $current_before = x_get_breadcrumb_current_before();
          $current_after  = x_get_breadcrumb_current_after();
          $page_title     = get_the_title();
          $blog_title     = get_the_title( get_option( 'page_for_posts', true ) );
          $post_parent    = $post->post_parent;
    
          if ( X_WOOCOMMERCE_IS_ACTIVE ) {
            $shop_url   = x_get_shop_link();
            $shop_title = x_get_option( 'x_' . $stack . '_shop_title', __( 'The Shop', '__x__' ) );
            $shop_link  = '<a href="'. $shop_url .'">' . $shop_title . '</a>';
          }
    
          echo '<div class="x-breadcrumbs">';
          if ( $is_ltr ) {
            echo '<a href="' . $home_link . '">' . $home_text . '</a>' . $delimiter;
          }
    
            if ( is_home() ) {
    
              echo $current_before . $blog_title . $current_after;
    
            } elseif ( is_category() ) {
    
              $cat = get_category( get_query_var( 'cat' ), false );
              $parent_id = ( $cat !== null ) ? $cat->parent : false;
              $breadcrumbs = array();
    
              if ( is_rtl() ) {
                echo $current_before . single_cat_title( '', false ) . $current_after;
              }
    
              while ( $parent_id ) {
                $parent = get_category( $parent_id );
                if ( $parent !== null ) {
                  // does this parent also have a parent?
                  $cat = get_category( $parent_id, false );
                  $parent_id = ( $cat !== null && $cat->parent != 0 ) ? $cat->parent : false;
    
                  $parent = sanitize_category( $parent );
                  $breadcrumbs[] = '<a href="' . get_category_link( $parent->term_id ) . '">' . $parent->name . '</a>';
                }
              }
    
              if ( $is_ltr ) {
                $breadcrumbs = array_reverse( $breadcrumbs );
              }
    
              for ( $i = 0; $i < count( $breadcrumbs ); $i++ ) {
                if ( $is_rtl ) echo $delimiter;
                echo $breadcrumbs[$i];
                if ( $is_ltr ) echo $delimiter;
              }
    
              if ( $is_ltr ) {
                echo $current_before . single_cat_title( '', false ) . $current_after;
              }
    
            } elseif ( x_is_product_category() ) {
    
              if ( $is_ltr ) {
                echo $shop_link . $delimiter . $current_before . single_cat_title( '', false ) . $current_after;
              } else {
                echo $current_before . single_cat_title( '', false ) . $current_after . $delimiter . $shop_link;
              }
    
            } elseif ( x_is_product_tag() ) {
    
              if ( $is_ltr ) {
                echo $shop_link . $delimiter . $current_before . single_tag_title( '', false ) . $current_after;
              } else {
                echo $current_before . single_tag_title( '', false ) . $current_after . $delimiter . $shop_link;
              }
    
            } elseif ( is_search() ) {
    
              echo $current_before . __( 'Search Results for ', '__x__' ) . 'β€œ' . get_search_query() . '”' . $current_after;
    
            } elseif ( is_singular( 'post' ) ) {
    
              $cat = get_the_category();
              $cat = get_category( $cat[0], false );
              $category_id = $cat->term_id;
              $breadcrumbs = array();
    
              if ( is_rtl() ) {
                echo $current_before . $page_title . $current_after;
              }
    
              while ( $category_id ) {
                $cat = get_category( $category_id );
                if ( $cat !== null ) {
                  // Loop through parent categories
                  $category_id = ( $cat !== null && $cat->parent != 0 ) ? $cat->parent : false;
                  $cat = sanitize_category( $cat );
                  $breadcrumbs[] = '<a href="' . get_category_link( $cat->term_id ) . '">' . $cat->name . '</a>';
                }
              }
    
              if ( $is_ltr ) {
                $breadcrumbs = array_reverse( $breadcrumbs );
              }
    
              for ( $i = 0; $i < count( $breadcrumbs ); $i++ ) {
                if ( $is_rtl ) echo $delimiter;
                echo $breadcrumbs[$i];
                if ( $is_ltr ) echo $delimiter;
              }
    
              if ( $is_ltr ) {
                echo $current_before . $page_title . $current_after;
              }
    
            } elseif ( x_is_portfolio() ) {
    
              echo $current_before . get_the_title() . $current_after;
    
            } elseif ( x_is_portfolio_item() ) {
    
              $link  = x_get_parent_portfolio_link();
              $title = x_get_parent_portfolio_title();
    
              if ( $v = get_breadcrumb_category('portfolio-category') ) {
                $portfolio_category = $delimiter . $v;
              } else {
                $portfolio_category = '';
              }
    
              if ( $is_ltr ) {
                echo '<a href="' . $link . '">' . $title . '</a>' . $portfolio_category . $delimiter . $current_before . $page_title . $current_after;
              } else {
                echo $current_before . $page_title . $current_after . $portfolio_category . $delimiter . '<a href="' . $link . '">' . $title . '</a>';
              }
    
            } elseif ( x_is_product() ) {
    
             if ( $v = get_breadcrumb_category('product_cat') ) {
               $product_category = $delimiter . $v;
             } else {
               $product_category = '';
             }
    
              if ( $is_ltr ) {
                echo $shop_link . $product_category . $delimiter . $current_before . $page_title . $current_after;
              } else {
                echo $current_before . $page_title . $current_after . $product_category . $delimiter . $shop_link;
              }
    
            } elseif ( x_is_buddypress() ) {
    
              if ( bp_is_group() ) {
                echo '<a href="' . bp_get_groups_directory_permalink() . '">' . x_get_option( 'x_buddypress_groups_title', __( 'Groups', '__x__' ) ) . '</a>' . $delimiter . $current_before . x_buddypress_get_the_title() . $current_after;
              } elseif ( bp_is_user() ) {
                echo '<a href="' . bp_get_members_directory_permalink() . '">' . x_get_option( 'x_buddypress_members_title', __( 'Members', '__x__' ) ) . '</a>' . $delimiter . $current_before . x_buddypress_get_the_title() . $current_after;
              } else {
                echo $current_before . x_buddypress_get_the_title() . $current_after;
              }
    
            } elseif ( x_is_bbpress() ) {
    
              remove_filter( 'bbp_no_breadcrumb', '__return_true' );
    
              if ( bbp_is_forum_archive() ) {
                echo $current_before . bbp_get_forum_archive_title() . $current_after;
              } else {
                echo bbp_get_breadcrumb();
              }
    
              add_filter( 'bbp_no_breadcrumb', '__return_true' );
    
            } elseif ( is_page() && ! $post_parent ) {
    
              echo $current_before . $page_title . $current_after;
    
            } elseif ( is_page() && $post_parent ) {
    
              $parent_id   = $post_parent;
              $breadcrumbs = array();
    
              if ( is_rtl() ) {
                echo $current_before . $page_title . $current_after . $delimiter;
              }
    
              while ( $parent_id ) {
                $page          = get_page( $parent_id );
                $breadcrumbs[] = '<a href="' . get_permalink( $page->ID ) . '">' . get_the_title( $page->ID ) . '</a>';
                $parent_id     = $page->post_parent;
              }
    
              if ( $is_ltr ) {
                $breadcrumbs = array_reverse( $breadcrumbs );
              }
    
              for ( $i = 0; $i < count( $breadcrumbs ); $i++ ) {
                echo $breadcrumbs[$i];
                if ( $i != count( $breadcrumbs ) -1 ) echo $delimiter;
              }
    
              if ( $is_ltr ) {
                echo $delimiter . $current_before . $page_title . $current_after;
              }
    
            } elseif ( is_tag() ) {
    
              echo $current_before . single_tag_title( '', false ) . $current_after;
    
            } elseif ( is_author() ) {
    
              GLOBAL $author;
              $userdata = get_userdata( $author );
              echo $current_before . __( 'Posts by ', '__x__' ) . 'β€œ' . $userdata->display_name . $current_after . '”';
    
            } elseif ( is_404() ) {
    
              echo $current_before . __( '404 (Page Not Found)', '__x__' ) . $current_after;
    
            } elseif ( is_archive() ) {
    
              if ( x_is_shop() ) {
                echo $current_before . $shop_title . $current_after;
              } else {
                echo $current_before . __( 'Archives ', '__x__' ) . $current_after;
              }
    
            }
    
          if ( $is_rtl ) {
            echo $delimiter . '<a href="' . $home_link . '">' . $home_text . '</a>';
          }
          echo '</div>';
    
        }
    
    }
    
    #1216962

    Rad
    Moderator

    Noted that! Yes, it would be a very nice feature.

    #1254304

    firatS
    Participant

    Hi,
    I also like to see sub categories breadcrumbs. Is the feature added ?

    Thanks,

    FΔ±rat

    #1254329

    firatS
    Participant

    Me too. I have 2 web sites with x theme and both need this functionality.

    #1254357

    Rad
    Moderator

    Hi there,

    It’s not yet implemented, but it’s on our list. Please stay tuned πŸ™‚

    Thanks!

    #1284536

    Pyanfar
    Participant

    I am assuming this hasn’t been resolved and none of the solutions I find fix it either, so a year later adding a +1 to the feature request. Shop breadcrumbs are a key customer navigation tool. They drill down and want to drill back up without using a browser back key esp on mobile.

    #1284623

    Lely
    Moderator

    Hello There,

    Thank you for adding the thread. I have update the request for this. We will let you know once we have an update.

    #1375304

    salilou
    Participant

    Here 1+ for this feature too.
    Several commercial website projects running x theme need product categories within breadcrumbs.

    #1375842

    Rue Nel
    Moderator

    We appreciate your feedback! We have forwarded this to our developers already.
    Once they’ll have this resolve, it will be updated and rolled out in our next update release.