<p>Yes, it is possible.</p>

<p>Pass the entry type handle to a segment and access that segment using the <code>craft.request</code> <a href="http://buildwithcraft.com/docs/templating/craft.request#getSegment" rel="nofollow"><code>getSegment()</code></a> method. Use this segment variable with the <code>craft.entries</code> <a href="http://buildwithcraft.com/docs/templating/craft.entries#type" rel="nofollow"><code>.type()</code></a> method to fetch only the entries of the given type. The example below assumes your entry type handle is in segment 2.</p>

<pre class="lang-twig prettyprint-override"><code>{% set entries = craft.entries.section('pages').type(craft.request.getSegment(2)) %}

{% for entry in entries %}
    &lt;li&gt;{{ entry.title }}&lt;/li&gt;
{% endfor %}
</code></pre>

CC BY-SA 3.0
2014-06-24T18:40:41.883Z
Would I need to set up a route in order to tell craft to use the template from the first segment? When I add another segment to the url I get a 404 error.
Jesse Bennett-Chamberlain
CC BY-SA 3.0
2014-06-24T19:41:44.370Z
Great point. If the URL that loads the template is tied to a Single or Section entry, yes, you should define a route.
Alex Kendrick
CC BY-SA 3.0
2014-06-21T13:57:36.043Z
2014-06-24T14:39:43.793Z
2014-06-24T14:39:43.793Z
Alex Kendrick
<p>I'm wondering if it's possible to dynamically filter a section list by entry type based on a url segment?</p>

<p>I'm hoping to avoid assigning a category to every entry.</p>

<entry-type><best-practice>
Is it possible to Filter entry types via the URL?
# Is it possible to Filter entry types via the URL?

(Asked by: username_0 on 2014-06-21)

I'm wondering if it's possible to dynamically filter a section list by entry type based on a url segment?

I'm hoping to avoid assigning a category to every entry.

**Tags:** entry-type, best-practice

---

## 1 answers

### Answer by username_1 on 2014-06-21. Score: 3 | Accepted answer

Yes, it is possible.
Pass the entry type handle to a segment and access that segment using the craft.request getSegment() method. Use this segment variable with the craft.entries .type() method to fetch only the entries of the given type. The example below assumes your entry type handle is in segment 2.
{% set entries = craft.entries.section('pages').type(craft.request.getSegment(2)) %}

{% for entry in entries %}
    {{ entry.title }}
{% endfor %}

> **Comments:**
> **username_0**: Would I need to set up a route in order to tell craft to use the template from the first segment? When I add another segment to the url I get a 404 error.  
> **username_1**: Great point. If the URL that loads the template is tied to a Single or Section entry, yes, you should define a route.  

---

