How to access to an specific policy on shop.policies

Viewed 15

im creating a individual template for each policy on site, how can i show only that specific policy on each template, here is code i made for that:

<div class="flex flex-col items-center my-8">
  {% for policy in shop.policies %}
    <h1 class="text-5xl font-bold tracking-tighter my-4 md:my-8">{{ policy.title }}</h1>
    <div class="py-2 mb-4 inline-flex items-center justify-center text-xs font-semibold tracking-tighter">
      <span class="mr-2">
        {{ 'general.last_updated' | t }}
      </span>
      {{ policy.published_at | date: '%d/%B/%Y' }}
    </div>
    <div class="max-w-5xl mx-auto px-4">{{ policy.body }}</div>
  {% endfor %}
</div>

i tried to access on policy object with handle filter like:

{{ policy['terms-of-service'].title }}

but it doesn't work, anyone is able to guide me how can i get it works? thanks in advance :)

EDIT:

here is code i have at the moment, with [shop.privacy_policy] but make an loop with that creating 2 policies on section.

<div class="flex flex-col items-center my-8">
  {% for policy in shop.policies %}
    <h1 class="text-5xl font-bold tracking-tighter my-4 md:my-8">{{ shop.privacy_policy.title }}</h1>
    <div class="py-2 mb-4 inline-flex items-center justify-center text-xs font-semibold tracking-tighter">
      <span class="mr-2">
        {{ 'general.last_updated' | t }}
      </span>
    </div>
    <div class="max-w-5xl mx-auto px-4">{{ shop.privacy_policy.body }}</div>
  {% endfor %}
</div>

and some image to show what i mean:

enter image description here

1 Answers
Related