<p>My <code>Category URL Formats</code> was set-up incorrectly. Or rather, I needed to go to <code>{handle}/{slug}</code> to see the proper result. </p>

CC BY-SA 3.0
2018-04-13T00:51:08.880Z
2018-04-13T00:51:08.880Z
Andrew Hahn
<p>Editing an index page that displays all entries within a structure. </p>

<p>Everything displays fine. </p>

<p>I add a category to a few entries and add <code>{% if category | length %}</code>and everything disappears as if no entries had a category. </p>

<p>I get no twig errors, so I presume my code is okay.</p>

<p>Here it is, just in case:</p>

<pre><code>          {% set entries = craft.entries.section('fellows').relatedTo(category) %}
      {% if category | length %}
        {% if entries | length %}
          {% for entry in entries %}
            {% for matrixBlock in entry.fellowsEntry %}
              {% if matrixBlock.type == 'entryContent' %}

                &lt;a href="{{ entry.url }}" class="portfolio-view bio"&gt; 
                    &lt;div class="portfolio-index inner bio m-white col-md-12"&gt;
                        {% for image in matrixBlock.fellowImage %} 
                           &lt;img src="{{ image.getUrl('sq300x300') }} " alt="" class="image-portfolio"&gt;
                         {% endfor %} 
                        &lt;h3 class="name text-center p22-ltp"&gt;{{ entry.title }}&lt;/h3&gt;
                        &lt;hr&gt;
                        &lt;h3 class="org text-center p22-ltp"&gt;{{ matrixBlock.organization }} &lt;/h3&gt;
                        &lt;hr&gt;
                        {{ category }}
                    &lt;/div&gt;&lt;/a&gt; 

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

CC BY-SA 3.0
2018-04-13T00:34:25.637Z
Are you setting `category` somewhere?
Jalen Davenport
CC BY-SA 3.0
2018-04-16T15:44:42.083Z
My understanding was that I am already in a category page and should have access to the {{ category }} model without having to set it.
Andrew Hahn
CC BY-SA 3.0
2018-04-16T15:46:57.527Z
Ah yes good point. My bad...
Jalen Davenport
<structure><filter><category>
Why are my entries disappearing when {% if category | length %} is added?
# Why are my entries disappearing when {% if category | length %} is added?

(Asked by: username_0 on 2018-04-13)

Editing an index page that displays all entries within a structure. 
Everything displays fine. 
I add a category to a few entries and add {% if category | length %}and everything disappears as if no entries had a category. 
I get no twig errors, so I presume my code is okay.
Here it is, just in case:
          {% set entries = craft.entries.section('fellows').relatedTo(category) %}
      {% if category | length %}
        {% if entries | length %}
          {% for entry in entries %}
            {% for matrixBlock in entry.fellowsEntry %}
              {% if matrixBlock.type == 'entryContent' %}

                 
                    
                        {% for image in matrixBlock.fellowImage %} 
                           
                         {% endfor %} 
                        {{ entry.title }}
                        
                        {{ matrixBlock.organization }} 
                        
                        {{ category }}
                     

             {% endif %}
          {% endfor %} 
        {% endfor %}   
      {% endif %}
    {% endif %}

**Tags:** structure, filter, category

> **Comments:**
> **username_1**: Are you setting `category` somewhere?  
> **username_0**: My understanding was that I am already in a category page and should have access to the {{ category }} model without having to set it.  
> **username_1**: Ah yes good point. My bad...  

---

## 1 answers

### Answer by username_0 on 2018-04-13. Score: 1

My `Category URL Formats` was set-up incorrectly. Or rather, I needed to go to `{handle}/{slug}` to see the proper result.


---

