jaw@jawtemplates.com

Show all categories in breadcrumbs

If you have structure of categories like this:

  • Category 1
    • Category 1-1
  • Category 2
    • Category 2-1

 

And if you want show in breadcrumbs bar all categories like this:

Home | Category 1 | Category 2 | Category 1-1 | Category 2-1 | Post name

 

So just try find code in /goodstore/template/simple-shortcodes/bereadcrumbs.php lines 139 – 150

//POST | CATEGORY
        $cats = get_the_category();
        if (isset($cats[0])) { // pokud neni v kategorii post neyobrazi se breadcrumb
            //Post
            $category = $cats[0]->name;
            $cat_id = $cats[0]->term_id;

            if (sizeof($category) > 0 && $category != '') {

                echo get_category_parents($cat_id, TRUE, $markup, FALSE);
            }
        }

 

and change it to this:

        //POST | CATEGORY
        $cats = get_the_category();
        $cats_breadcrumbs = array();
        foreach ((array) $cats as $k => $cat) {
            if (isset($cat)) { // pokud neni v kategorii post neyobrazi se breadcrumb
                //Post
                $category = $cat->name;
                $cat_id = $cat->term_id;

                if (sizeof($category) > 0 && $category != '') {
                    foreach ((array) explode('-=-', get_category_parents($cat_id, TRUE, '-=-', FALSE)) as $key => $c) {
                        if (!isset($cats_breadcrumbs[$key]) || !is_array($cats_breadcrumbs[$key])) {
                            $cats_breadcrumbs[$key] = array();
                        }
                        $cats_breadcrumbs[$key][$k] = $c;
                    }
                }
            }
        }
        foreach ($cats_breadcrumbs as $cat) {
            echo implode('', $cat);
        }
  • Was this Helpful ?
  • yes   no

Leave a Reply

You must be logged in to post a comment.