0

I wanted to add a static text with a link in front of my category page and product page breadcrumbs.

Existing Breadcrumbs:

Home > Category > Sub Category > Sub Category

How I want it to be

Home > Static Text with link > Category > Sub Category > Sub Category

Remember, my cms pages breadcrumbs need to remain as they are. Not like above.

-1

You need to make changes in the below file.

vendor/magento/module-theme/view/frontend/templates/html/breadcrumbs.phtml

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

?>
<?php if ($crumbs && is_array($crumbs)) : ?>
<div class="breadcrumbs">
    <ul class="items">
        <?php foreach ($crumbs as $crumbName => $crumbInfo) : ?>
            <li class="item <?= /* @escapeNotVerified */ $crumbName ?>">
            <?php if ($crumbInfo['link']) : ?>
                <a href="<?= /* @escapeNotVerified */ $crumbInfo['link'] ?>" title="<?= $block->escapeHtml($crumbInfo['title']) ?>"><?= $block->escapeHtml($crumbInfo['label']) ?></a>
            <?php elseif ($crumbInfo['last']) : ?>
                <strong><?= $block->escapeHtml($crumbInfo['label']) ?></strong>
            <?php else: ?>
                <?= $block->escapeHtml($crumbInfo['label']) ?>
            <?php endif; ?>
            </li>
            <?php 
            //custom code by John
           //your customer code here, 
            if ($crumbName == "home") : ?>
                <li class="item">
                    <a href="Your static link here" title="">Your static link title here</a>
                </li>
          <?php endif; ?>
        <?php endforeach; ?>
    </ul>
</div>
<?php endif; ?>

see above and make the necessary changes in the same file. Note: it will be preferable if you can override this file. How to override .phtml files in Magento 2 Also, change href link and title on the above code. To check if the current page is cms page or category page Magento 2.2.2 how to check if current page is a CMS page in .phtml file?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.