Hi there,
I' have two collections on my homepage: 'women's t-shirts' and 'men's t-shirts'. I want to hyperlink the title of these featured collections to the correct collection page.
I have used the code below to add a hyperlink to the title, but it means both of the collections on my homepage link to the 'men's t-shirts' collection. I want the women's collections to link to women's shirts.
How do I single out the title 'women's t-shirts' to link to the correct collection?
Help much appreciated!
<div class="index-section home-section feature-collection feature-collection--{{ section.id }}" data-section-id="{{ section.id }}" data-section-type="feature-collection"> <div class="wrapper wrapper--margins bottom--space"> {%- assign collection = collections[section.settings.collection] -%} {% if section.settings.heading != blank %} {% if section.settings.show_view_all %} <div class="grid"> <div class="grid__item large--three-quarters small--one-whole medium--one-whole"> {% endif %} <h2 class="home-section-title"> <a href="{{ "https://bornhybrid.com/collections/mens-eco-t-shirts" }}"> {{ section.settings.heading | escape }}</h2> {% if section.settings.show_view_all %} </div> <div class="grid__item large--one-quarter small--one-whole medium--one-whole text-right medium-down--text-center view-all"> <a href="https://bornhybrid.com/collections"> <span>{{ 'collections.general.view_all' | t }}</span> {% include "asset_svg" with "arrow_right" %}</a>
Solved! Go to the solution
This is an accepted solution.
Hi,
Change your code to bellow:
<a href="{{ collection.url }}">
Let me know if you need help.
You can add this link in your featured collection section with title:
<a href="{{ collection.url }}">{{ collection.title }}</a>
Hi, where can I paste this in my simple theme ?
At the moment, it looks like this :
<div class="feature-row"> {% if section.settings.layout == 'left' %} {{ image_layout }} {% endif %} <div class="feature-row__item feature-row__text feature-row__text--{{ section.settings.layout }}"> {% if section.settings.title != blank %} <h2 class="small--text-center">{{ section.settings.title | escape }}</h2> {% endif %} {% if section.settings.text != blank %} <div class="rte-setting featured-row__subtext">{{ section.settings.text }}</div> {% endif %} {% if section.settings.button_label != blank and section.settings.button_link != blank %} <a href="{{ section.settings.button_link }}" class="btn"> {{ section.settings.button_label | escape }} </a> {% endif %} </div>
I think you have below is for title:
<h2 class="small--text-center">{{ section.settings.title | escape }}</h2>
So if its collection page then make it like:
<a href="{{ collection.url }}"> <h2 class="small--text-center">{{ section.settings.title | escape }}</h2> </a>
User | Count |
---|---|
568 | |
209 | |
129 | |
82 | |
45 |