2

Is there a way to pass value of an entries field into category URI format?

{% if object.level == 1 %}

{slug}-{entries.one().slug}

{% else %}

{slug}-{parent.uri}

{% endif %}

Thanks.

2

If your entries field is in the layout of your category

{% if object.level == 1 %}
    {% set entry = object.entriesFieldHandle.one() %}
    {slug}-{{ entry? entry.slug : '' }}
{% else %}
    {slug}-{parent.uri}
{% endif %}
  • The entries field is in layout of the entry itself where the category assigned to. – Mark H. Mar 10 at 19:38
  • I would highly suggest to not that if you care a little bit about SEO then – Robin Schambach Mar 10 at 19:39
  • Still looking for solution. – Mark H. Mar 10 at 19:59
  • 1
    Then grab the entry that is related to your category {% set entry = craft.entries.relatedaTo(object).one() %} but keep in mind this will always a different one so your url will always change – Robin Schambach Mar 10 at 20:00

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.