Forum

Thread tagged as: Problem, Runway, Blog

Blog Category in Breadcrumb

I am having trouble getting the blog category to correctly show in the site's breadcrumb.

See the url to the blog here https://vlm.so53dev.co.uk/blog/

If you click on the category 'Car News and Info' you will see the breadcrumb change and looks fine as per this screenshot https://www.evernote.com/shard/s559/sh/0ef9bbbf-60db-446b-8c8e-c191fc0de91f/c40fc809bcb8307b

However, if you click on the category 'Mercedes' (or 'Volkswagen') you will see the url changes as expected but the breadcrumb stays as 'Car News and Info' as per this screenshot https://www.evernote.com/l/Ai_vaqjKeWBEZ6sjz9EOcw_9_MjMbm6tFQA

Code in archive.php is

perch_blog_categories(array(
                'category'   => perch_get('cat'),
                'template' => 'breadcrumb-cat.html',
                'count' => 1,



    ));

the code in breadcrumb-cat.html is

    <div class="utility-bar">
        <div class="container">
            <div class="row">
                <div class="col-md-8 col-sm-6 col-xs-8">
                    <ol class="breadcrumb">
                        <li><a href="/">Home</a></li>
                        <li itemscope="" itemtype="https://data-vocabulary.org/Breadcrumb"><a itemprop="url" href="/blog/"><span itemprop="title">Blog</span></a></li>
                        <li itemscope="" itemtype="https://data-vocabulary.org/Breadcrumb"><span itemprop="title">Category  </span></li>
                        <li class="active" itemscope="" itemtype="https://data-vocabulary.org/Breadcrumb"><span itemprop="title"><perch:category id="catTitle" /></span></li>
                    </ol>
                </div>

The 'Car News and Info' category is a category that both blog posts are also in, if that helps.

Neil Duddridge

Neil Duddridge 1 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Use perch_blog_category() to display the details of a category.

Can you give me an example?

Ah figured it out :)

change my archive.php from this

perch_blog_categories(array(
'category' => perch_get('cat'),
'template' => 'breadcrumb-cat.html',
'count' => 1,
));

to

perch_layout('global/breadcrumb-blog');

and then created breadcrumb-blog.php file to include this:

  <div class="utility-bar">
        <div class="container">
            <div class="row">
                <div class="col-md-8 col-sm-6 col-xs-8">
                    <ol class="breadcrumb">
                        <li><a href="/">Home</a></li>
                        <li itemscope="" itemtype="https://data-vocabulary.org/Breadcrumb"><a itemprop="url" href="/blog/"><span itemprop="title">Blog</span></a></li>
                        <li itemscope="" itemtype="https://data-vocabulary.org/Breadcrumb"><span itemprop="title">Category  </span></li>
                        <li class="active" itemscope="" itemtype="https://data-vocabulary.org/Breadcrumb">
                           <span itemprop="title">
                          <?php perch_blog_category(perch_get('cat')); ?>
                          </span>
                        </li>
                    </ol>
                </div>