Using collection reference metafield on collection pages

Using collection reference metafield on collection pages

Justin_Brown
Shopify Partner
26 0 4

Hi,

 

I'm hoping someone could help me with this. I have something similar working on my product pages whereby I'm using a collection reference metafield to show a link to a collection. I'd also like to get it to work on a collection page so that I can show on a specific collection a link to a different collection based on what I enter in the "Parent Collection" metafield.

 

This code doesn't seem to display anything, which to someone who knows what they're doing will probably seem obvious! Could someone please help me to get this working?

 

{% assign parentcollection = collection.metafields.custom.parent_collection %}
<a href="{{ parentcollection.url }}" title="{{ parentcollection.title }}">{{ parentcollection.title }}

Thank you.

Reply 1 (1)

Justin_Brown
Shopify Partner
26 0 4

To answer my own question it looks simple, I just didn't know where to look to find this out until just now! 

 

{{ collection.metafields.custom.parent_collection.value.title }}
{{ collection.metafields.custom.parent_collection.value.url }}