Re: How do I change the code for breadcrumbs in the master theme?

How do I change the code for breadcrumbs in the master theme?

Valeria_16
Shopify Partner
17 0 2

what to do if a link redirect is made
https://ucghdd.com/collections/digitrak-falcon-f5/products/used-digitrak-falcon-f5-locator-receiver-...  on  https://ucghdd.com/products/used-digitrak-falcon-f5-locator-receiver-stock-number-a391
and because of this, the breadcrumbs do not work correctly, they do not display the desired collection.

 

this is the code that is currently used for bread crumbs. but due to the fact that the name of the collection is not displayed in the link, the collection is not displayed.

 

{% assign search_category = search_category | default: blank %}
{% assign show_breadcrumbs = true %}

{% if show_breadcrumbs %}
{% capture cat_array %}{%- render 'advanced-tag-loop' -%}{% endcapture %}
{% assign cat_array = cat_array | split: '|' %}

{%- capture delimiter -%}
<span class="breadcrumbs-delimiter" aria-hidden="true">
{% render 'icon-chevron-down-thin' %}
</span>
{%- endcapture -%}

<nav
class="breadcrumbs-container"
aria-label="{{ 'general.accessibility.nav_breadcrumbs' | t }}"
>
<a href="{{ routes.root_url }}">{{ 'general.breadcrumbs.home' | t }}</a>
{% if template contains 'page' %}

{{ delimiter }}
<span>{{ page.title }}</span>

{% elsif template contains 'product' %}

{% if collection.url %}
{{ delimiter }}
{{ collection.title | link_to: collection.url }}
{% endif %}
{{ delimiter }}
<span>{{ product.title }}</span>

{% elsif template contains 'list-collections' %}

{{ delimiter }}
<span>{{ 'general.breadcrumbs.collections' | t }}</span>

{% elsif template contains 'collection' and collection.handle %}

{{ delimiter }}
{% if current_tags %}
{% capture url %}{{ routes.collections_url }}/{{ collection.handle }}{% endcapture %}
{{ collection.title | link_to: url }}
{{ delimiter }}

{% for tag in current_tags %}

{% assign is_advanced_tag = false %}
{% assign cat = tag | split: '_' | first %}
{% unless cat == tag %}
{% if cat_array contains cat %}
{% assign is_advanced_tag = true %}
<span class="breadcrumbs-tag">
{{ tag | remove_first: cat | remove_first: '_' }}
</span>
{% endif %}
{% endunless %}

{% unless is_advanced_tag %}
<span class="breadcrumbs-tag">{{ tag }}</span>
{% endunless %}

{% unless forloop.last %}
<span class="breadcrumbs-tag">+</span>
{% endunless %}
{% endfor %}
{% else %}
<span>{{ collection.title }}</span>
{% endif %}

{% elsif template == 'blog' %}

{{ delimiter }}
{% if current_tags %}
{{ blog.title | link_to: blog.url }}
{{ delimiter }}
<span>{{ current_tags | join: " + " }}</span>
{% else %}
<span>{{ blog.title }}</span>
{% endif %}

{% elsif template == 'article' %}

{{ delimiter }}
{{ blog.title | link_to: blog.url }}
{{ delimiter }}
<span>{{ article.title }}</span>

{% elsif template contains 'search' and search.performed %}
{% capture sanitized_terms %}
{%
render 'search-sanitizer',
search_terms: search.terms
%}
{% endcapture %}

{% assign sanitized_terms = sanitized_terms | strip %}

{{ delimiter }}

{% if search_category != blank %}
<span>
{{
'search.general.breadcrumbs_count_when_filtered'
| t: terms: sanitized_terms, category: search_category, count: search.results_count
}}
</span>
{% else %}
<span>{{ 'search.general.breadcrumbs_count' | t: terms: sanitized_terms, count: search.results_count, results: results }}</span>
{% endif %}

{% else %}

{{ delimiter }}
<span>{{ page_title }}</span>

{% endif %}
</nav>
{% endif %}

 

 

Reply 1 (1)

Raj-webdesigner
Shopify Partner
344 84 82

Try This breadcrumbs 

replace your breadcrumbs code with this code

{% assign search_category = search_category | default: blank %}
{% assign show_breadcrumbs = true %}

{% if show_breadcrumbs %}
  {% capture cat_array %}{% render 'advanced-tag-loop' %}{% endcapture %}
  {% assign cat_array = cat_array | split: '|' %}
  {% capture delimiter %}
    <span class="breadcrumbs-delimiter" aria-hidden="true">
      {% render 'icon-chevron-down-thin' %}
    </span>
  {% endcapture %}

  <nav class="breadcrumbs breadcrumbs-container" aria-label="{{ 'general.accessibility.nav_breadcrumbs' | t }}">
    <ul>
        <li class="breadcrumb-item"><a href="/" class="{% if product_collection.url != blank %}show{% endif %}">Home</a></li>
        {% if template contains 'product' %}
          {% assign product_collection = collections[product.collections.first.handle] %}
          {% if product_collection %}
            <li class="breadcrumb-item"><a href="{{ product_collection.url }}" class="{% if product.title != blank or part != blank %}show{% endif %}">{{ product_collection.title }}</a></li>
          {% endif %}
          <li class="breadcrumb-item">{{ product.title }}</li>
        {% else %}
          {% if collection %}
            <li class="breadcrumb-item"><a href="{{ collection.url }}">{{ collection.title }}</a></li>
            {% else %}
            {% for part in page.url %}
              {% unless part == blank %}
                <li class="breadcrumb-item">{{ part | replace: '-', ' ' | capitalize }}</li>
              {% endunless %}
            {% endfor %}
          {% endif %}
        {% endif %}
      </ul>
    
    {% if template contains 'page' %}
      {% for tag in current_tags %}
        {% assign is_advanced_tag = false %}
        {% assign cat = tag | split: '_' | first %}
        {% unless cat == tag %}
          {% if cat_array contains cat %}
            {% assign is_advanced_tag = true %}
            <span class="breadcrumbs-tag">{{ tag | remove_first: cat | remove_first: '_' }}</span>
          {% endif %}
        {% endunless %}
        {% unless is_advanced_tag %}
          <span class="breadcrumbs-tag">{{ tag }}</span>
        {% endunless %}
        {% unless forloop.last %}
          <span class="breadcrumbs-tag">+</span>
        {% endunless %}
      {% endfor %}
    
    {% elsif template == 'blog' %}
      {{ delimiter }}
      {% if current_tags %}
        {{ blog.title | link_to: blog.url }}
        {{ delimiter }}
        <span>{{ current_tags | join: " + " }}</span>
      {% else %}
        <span>{{ blog.title }}</span>
      {% endif %}
    
    {% elsif template == 'article' %}
      {{ delimiter }}
      {{ blog.title | link_to: blog.url }}
      {{ delimiter }}
      <span>{{ article.title }}</span>
    
    {% elsif template contains 'search' and search.performed %}
      {% capture sanitized_terms %}
        {% render 'search-sanitizer', search_terms: search.terms %}
      {% endcapture %}
      {% assign sanitized_terms = sanitized_terms | strip %}
      {{ delimiter }}
      {% if search_category != blank %}
        <span>{{ 'search.general.breadcrumbs_count_when_filtered' | t: terms: sanitized_terms, category: search_category, count: search.results_count }}</span>
      {% else %}
        <span>{{ 'search.general.breadcrumbs_count' | t: terms: sanitized_terms, count: search.results_count, results: results }}</span>
      {% endif %}
    {% endif %}
  </nav>
{% endif %}

 

Are you looking for Shopify Developer then your search is over I will help you


If you require further help to optimize your store, please don’t hesitate to reach out.


This contribution will always benefit you and you will get my full help easily and you can contact me easily.


Your Willpower Contribution Link

:-

❤️Tip❤️

Contect On My Mail :-Mail@gmail.com