Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-13T00:51:08.880Z
Answers.LastActivityDate: 2018-04-13T00:51:08.880Z
Answers.UserDisplayName: Andrew Hahn
Body: <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>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-04-13T00:34:25.637Z
Comments.Text: Are you setting `category` somewhere?
Comments.UserDisplayName: Jalen Davenport
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-04-16T15:44:42.083Z
Comments.Text: My understanding was that I am already in a category page and should have access to the {{ category }} model without having to set it.
Comments.UserDisplayName: Andrew Hahn
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-04-16T15:46:57.527Z
Comments.Text: Ah yes good point. My bad...
Comments.UserDisplayName: Jalen Davenport
Tags: <structure><filter><category>
Title: Why are my entries disappearing when {% if category | length %} is added?
ThreadText: # 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' %}
  
                  <a href="{{ entry.url }}" class="portfolio-view bio"> 
                      <div class="portfolio-index inner bio m-white col-md-12">
                          {% for image in matrixBlock.fellowImage %} 
                             <img src="{{ image.getUrl('sq300x300') }} " alt="" class="image-portfolio">
                           {% endfor %} 
                          <h3 class="name text-center p22-ltp">{{ entry.title }}</h3>
                          <hr>
                          <h3 class="org text-center p22-ltp">{{ matrixBlock.organization }} </h3>
                          <hr>
                          {{ category }}
                      </div></a> 
  
               {% 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.
  
  
  ---
  
  