Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #16025

    hi kriesi team,

    my current structure is

    Products (parent product category)

    - Bag (child product category)

    - Bag 1 (a single product page)

    Currently when i go to the single product page it shows:

    Home » Products » Bag1

    But I would like to show:

    Home » Products » Bag » Bag1

    I have an issue that is similar to this post

    http://www.kriesi.at/support/topic/how-to-get-parent-category-in-breadcrumbs-on-the-single-product-page

    I can only do front end design and this coding is not easy for me to grasp.

    I tried going into the one of the referred links posted by Peter http://www.kriesi.at/support/topic/breadcrumbs-glitching-illogical-structure in one of the thread which is taking me to abundanceframeworkphpclass-breadcrumb.php

    saw the codes that solved the issue, but cant figure out how to insert below codes given by Peter


    $prod_cat = array();

    $id = (int) get_the_ID();

    $taxonomy = ‘product_cat’;

    if ( !empty($id) && !empty($taxonomy) )

    {

    $args = array(‘orderby’ => ‘term_id’, ‘order’ => ‘ASC’, ‘fields’ => ‘all’);

    $prod_cat = wp_get_object_terms( $id, $taxonomy, $args );

    wp_cache_add($id, $prod_cat, $taxonomy . ‘_relationships’);

    $prod_cat = apply_filters( ‘get_the_terms’, $prod_cat, $id, $taxonomy );

    }

    if (!empty($prod_cat))

    {

    $trail_array = ”;

    $parent_cats = array();

    foreach ($prod_cat as $cat) {

    if(!empty($cat->parent))

    {

    if (!in_array($cat->parent, $parent_cats, false)) $parent_cats[] = (int) $cat->parent;

    }

    else

    {

    if (!in_array(0, $parent_cats, false)) $parent_cats[] = (int) 0;

    }

    }

    $i = 0;

    foreach ($parent_cats as $parent_cat) {

    foreach ($prod_cat as $cat) {

    if ( !empty($cat->name) && isset($cat->parent) && $cat->parent == $parent_cat )

    {

    if ( $i == 0 )

    {

    $trail_array .= ‘slug, $taxonomy ) .’”>’ . $cat->name . ‘,’;

    }

    else

    {

    $trail_array .= ‘ <span class=”sep”>’ . $separator . ‘</span> ‘ . ‘slug, $taxonomy ) .’”>’ . $cat->name . ‘,’;

    }

    }

    }

    $trail_array = (substr($trail_array,-1) == ‘,’) ? substr($trail_array, 0, -1) : $trail_array;

    $i++;

    }

    $trail[] = $trail_array;

    }

    }


    Can anyone help please?

    #89851

    Hi anyone can help with this issue ? Thxs alot

    #89852

    Hi still can’t solve this..anyone can help?

    #89853

    Hi papachew,

    I’m tagging the team to this.

    Regards,

    Mya

    #89854

    Hi,

    Initially I was also a bit confused, but turns out its home is line 270 of the class-breadcrumbs.php in /framework/php/ folder in the theme. The example has an extra curly brace, so please grab this below, make a backup of the above named file, and then paste the block on line 270

    $prod_cat = array();
    $id = (int) get_the_ID();
    $taxonomy = 'product_cat';
    if (!empty($id) && !empty($taxonomy) ) {
    $args = array('orderby' => 'term_id', 'order' => 'ASC', 'fields' => 'all');
    $prod_cat = wp_get_object_terms($id, $taxonomy, $args );
    wp_cache_add($id, $prod_cat, $taxonomy . '_relationships');
    $prod_cat = apply_filters('get_the_terms', $prod_cat, $id, $taxonomy );
    }
    if (!empty($prod_cat)) {
    $trail_array = '';
    $parent_cats = array();
    foreach($prod_cat as $cat) {
    if (!empty($cat->parent)) {
    if (!in_array($cat->parent, $parent_cats, false)) {
    $parent_cats[] = (int) $cat->parent;
    }
    } else {
    if (!in_array(0, $parent_cats, false)) {
    $parent_cats[] = (int) 0;
    }
    }
    }
    $i = 0;
    foreach($parent_cats as $parent_cat) {
    foreach($prod_cat as $cat) {
    if (!empty($cat->name) && isset($cat->parent) && $cat->parent == $parent_cat ) {
    if ($i == 0 ) {
    $trail_array .= '<a href="'. get_term_link($cat->slug, $taxonomy ) .'">' . $cat->name . '</a>,';
    } else {
    $trail_array .= ' <span class="sep">' . $separator . '</span> ' . '<a href="'. get_term_link($cat->slug, $taxonomy ) .'">' . $cat->name . '</a>,';
    }
    }
    }
    $trail_array = (substr($trail_array,-1) == ',') ? substr($trail_array, 0, -1) : $trail_array;
    $i++;
    }
    $trail[] = $trail_array;
    }

    Please let us know how it went.

    Thanks,

    Nick

    #89855

    Thku mya appreciate it

    #89856

    Hi nick, thxs for responding i will give it a try

    #89857

    hi nick,

    It work!!!!

    Thxs alot man! finally!!

    thxs again!

Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘breadcrumbs issue’ is closed to new replies.