<p>If your entries field is in the layout of your category</p>

<pre class="lang-TWIG prettyprint-override"><code>{% if object.level == 1 %}
    {% set entry = object.entriesFieldHandle.one() %}
    {slug}-{{ entry? entry.slug : '' }}
{% else %}
    {slug}-{parent.uri}
{% endif %}
</code></pre>

CC BY-SA 4.0
2019-03-10T19:38:43.873Z
The entries field is in layout of the entry itself where the category assigned to.
Mark H.
CC BY-SA 4.0
2019-03-10T19:39:38.223Z
I would highly suggest to not that if you care a little bit about SEO then
Robin Schambach
CC BY-SA 4.0
2019-03-10T19:59:02.527Z
Still looking for solution.
Mark H.
CC BY-SA 4.0
2019-03-10T20:00:13.580Z
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
CC BY-SA 4.0
2019-03-10T18:31:35.500Z
2019-03-10T18:31:35.500Z
Robin Schambach
<p>Is there a way to pass value of an entries field into category URI format?</p>

<pre><code>{% if object.level == 1 %}

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

{% else %}

{slug}-{parent.uri}

{% endif %}
</code></pre>

<p>Thanks.</p>

<url>
Entries field in categories URI
# Entries field in categories URI

(Asked by: username_0 on 2019-03-10)

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.

**Tags:** url


---

## 1 answers

### Answer by username_1 on 2019-03-10. Score: 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 %}

> **Comments:**
> **username_0**: The entries field is in layout of the entry itself where the category assigned to.  
> **username_1**: I would highly suggest to not that if you care a little bit about SEO then  
> **username_0**: Still looking for solution.  
> **username_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  

---

