Answers.Body: <p>I'm rolling the same thing with </p>
  
  <pre><code>{% extends 'layouts/_entry_layout' %}
  {# sets the name for the css file to be pulled #}
  {% set pageType = 'search' %}
  {% set catSlug = craft.request.getSegment(2) %}
  {% set title = craft.categories.slug(catSlug).first() ~ ' Channel' %}
  
  {% block content %}
  
  &lt;section class="search-results"&gt;
  
  {% paginate craft.entries.relatedTo(category) as entriesOnPage %}
  
  
  &lt;h1 class="category__title"&gt;{{ category.title }}&lt;/h1&gt;
  
      {% for entry in entriesOnPage %}
          {% include 'modules/_article_listing' %}
      {% endfor %}
  
  {% include 'inc/_pagination' %}
  
  {% endpaginate %}
  
  &lt;/section&gt;
  
  {% endblock %}
  </code></pre>
  
  <p>my article listing module contains the usual things like {{ entry.title }} etc</p>
  
  <p>and pagination include is like so:</p>
  
  <pre><code>{% if paginate %}
  
  {% set currentPage = paginate.currentPage %}
  {% set startPage = currentPage - 2 %}
  {% set endPage = currentPage + 2 %}
  {% if query is defined %}
  {% set queryString = "?q=" ~ query %}
  {% endif %}
  
  
  {% if paginate.totalPages &gt; 1 %}
  &lt;nav class="pagination" role="navigation"&gt;
  
      &lt;ol class="pagination__list"&gt;
  
          {% if paginate.prevUrl %}
          &lt;li class="pagination__item"&gt;
              &lt;a class="btn  btn-2  btn-2a" href="{{ paginate.prevUrl }}{% if queryString is defined %}{{ queryString }}{% endif %}"&gt;
                  &amp;larr;
                  &lt;span class="visuallyhidden"&gt;Previous Page&lt;/span&gt;
              &lt;/a&gt;
          &lt;/li&gt;
          {% endif %}
          {% for i in startPage..endPage %}
          {% if paginate.getPageUrl( i ) %}
          {% if i != currentPage %}
  
          &lt;li class="pagination__item"&gt;
              &lt;a class="btn  btn-2  btn-2a" href="{{ paginate.getPageUrl( i ) }}{% if queryString is defined %}{{ queryString }}{% endif %}"&gt;
                  &lt;span class="visuallyhidden"&gt;Page &lt;/span&gt;{{ i }}
              &lt;/a&gt;
          &lt;/li&gt;
  
          {% else %}
  
          &lt;li class="pagination__item btn  -current"&gt;
              &lt;span class="visuallyhidden"&gt;Current Page &lt;/span&gt;{{ i }}
          &lt;/li&gt;
  
          {% endif %}
      &lt;/li&gt;
      {% endif %}
      {% endfor %}
  
      {% if paginate.nextUrl %}
      &lt;li class="pagination__item"&gt;
          &lt;a class="btn  btn-2  btn-2a" href="{{ paginate.nextUrl }}{% if queryString is defined %}{{ queryString }}{% endif %}"&gt;
              &lt;span class="visuallyhidden"&gt;Next Page&lt;/span&gt;
              &amp;rarr;
          &lt;/a&gt;
      &lt;/li&gt;
      {% endif %}
  
  &lt;/ol&gt;
  
  
  
  &lt;/nav&gt;
  {% endif %}
  
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-27T20:07:12.257Z
Answers.LastActivityDate: 2015-05-27T20:07:12.257Z
Answers.UserDisplayName: Steven Grant
Answers.Body: <p>My category field was inside a Matrix field.</p>
  
  <p>These links helped with the twig logic:</p>
  
  <p><a href="https://craftcms.stackexchange.com/questions/4830/is-it-possible-to-have-category-listing-page-of-entries-if-the-category-is-defin?rq=1">Is it possible to have category listing page of entries if the category is defined within a matrix block inside said entries?</a></p>
  
  <p><a href="https://craftcms.stackexchange.com/questions/8463/find-entries-that-have-a-category-selected-from-a-category-field-within-a-matrix">Find entries that have a category selected from a category field within a matrix block</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-27T23:27:22.873Z
Answers.LastActivityDate: 2015-05-27T23:27:22.873Z
Answers.UserDisplayName: Niall Thompson
Body: <p>I am trying to display entries based on the last segment in the url and then paginate.</p>
  
  <p>Here's what I have so far but it's not displaying any entries:</p>
  
  <pre><code>{% set categorySlug = craft.request.getLastSegment() %}
    {% set category = craft.categories.slug(categorySlug).first() %}
  
    {% if category %}
  
        {% set entries = craft.entries.relatedTo(category).limit(12) %}
        &lt;ul&gt;
  
        {% paginate entries as entries %}
  
        {% for entry in entries %}
  
        {% for block in entry.resource.type('resource') %}
  
        &lt;li class="summary m-all t-all d-all"&gt;
        &lt;a href="{{ entry.url }}"&gt;
        &lt;article&gt;
        &lt;header class="article-header"&gt;
        &lt;h1&gt;{{ block.resourceTitle }}&lt;/h1&gt;
        &lt;h5&gt;{{ block.resourceAuthors }}&lt;/h5&gt;
        &lt;p&gt;{{ block.resourceSummary }}
        &lt;span class="link"&gt;Read more&lt;/span&gt;
        &lt;/p&gt;
        &lt;/header&gt;
        &lt;/article&gt;
        &lt;/a&gt;
        &lt;/li&gt;
        &lt;hr class="m-all t-all d-all"&gt;
  
        {% endfor %}
  
        {% endfor %}
  
        &lt;/ul&gt;
  
        {% if paginate.prevUrl %}
            &lt;a href="{{ paginate.prevUrl }}"&gt;Previous&lt;/a&gt;
        {% endif %}
  
        {% if paginate.nextUrl %}
            &lt;a href="{{ paginate.nextUrl }}"&gt;Next&lt;/a&gt;
        {% endif %}
        {% endpaginate %}
  
    {% endif %}
  </code></pre>
  
  <p>Even this simplified version outputs zero entries:</p>
  
  <pre><code>  {% set categorySlug = craft.request.getLastSegment() %}
    {% set category = craft.categories.slug(categorySlug).first() %}
  
    {% set entries = craft.entries.relatedTo(category) %}
  
    {# Output them #}
    {% for entry in entries %}
        &lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;
    {% endfor %}
  </code></pre>
  
  <p>Any thoughts?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-27T20:07:09.410Z
Comments.Text: Your simplified version, which is generic enough for me to test without modification, works fine for me. So, I'm wondering if the problem doesn't lie elsewhere than in the code snippet.
Comments.UserDisplayName: Jack McKenzie
Tags: <entries><categories><pagination>
Title: Display Category Entries Based on Slug
ThreadText: # Display Category Entries Based on Slug
  
  (Asked by: username_0 on 2015-05-27)
  
  I am trying to display entries based on the last segment in the url and then paginate.
  
  Here's what I have so far but it's not displaying any entries:
  
  ```
  {% set categorySlug = craft.request.getLastSegment() %}
    {% set category = craft.categories.slug(categorySlug).first() %}
  
    {% if category %}
  
        {% set entries = craft.entries.relatedTo(category).limit(12) %}
        <ul>
  
        {% paginate entries as entries %}
  
        {% for entry in entries %}
  
        {% for block in entry.resource.type('resource') %}
  
        <li class="summary m-all t-all d-all">
        <a href="{{ entry.url }}">
        <article>
        <header class="article-header">
        <h1>{{ block.resourceTitle }}</h1>
        <h5>{{ block.resourceAuthors }}</h5>
        <p>{{ block.resourceSummary }}
        <span class="link">Read more</span>
        </p>
        </header>
        </article>
        </a>
        </li>
        <hr class="m-all t-all d-all">
  
        {% endfor %}
  
        {% endfor %}
  
        </ul>
  
        {% if paginate.prevUrl %}
            <a href="{{ paginate.prevUrl }}">Previous</a>
        {% endif %}
  
        {% if paginate.nextUrl %}
            <a href="{{ paginate.nextUrl }}">Next</a>
        {% endif %}
        {% endpaginate %}
  
    {% endif %}
  
  ```
  
  Even this simplified version outputs zero entries:
  
  ```
    {% set categorySlug = craft.request.getLastSegment() %}
    {% set category = craft.categories.slug(categorySlug).first() %}
  
    {% set entries = craft.entries.relatedTo(category) %}
  
    {# Output them #}
    {% for entry in entries %}
        <a href="{{ entry.url }}">{{ entry.title }}</a>
    {% endfor %}
  
  ```
  
  Any thoughts?
  
  **Tags:** entries, categories, pagination
  
  > **Comments:**
  > **username_1**: Your simplified version, which is generic enough for me to test without modification, works fine for me. So, I'm wondering if the problem doesn't lie elsewhere than in the code snippet.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2015-05-27. Score: 1
  
  I'm rolling the same thing with
  
  ```
  {% extends 'layouts/_entry_layout' %}
  {# sets the name for the css file to be pulled #}
  {% set pageType = 'search' %}
  {% set catSlug = craft.request.getSegment(2) %}
  {% set title = craft.categories.slug(catSlug).first() ~ ' Channel' %}
  
  {% block content %}
  
  <section class="search-results">
  
  {% paginate craft.entries.relatedTo(category) as entriesOnPage %}
  
  <h1 class="category__title">{{ category.title }}</h1>
  
      {% for entry in entriesOnPage %}
          {% include 'modules/_article_listing' %}
      {% endfor %}
  
  {% include 'inc/_pagination' %}
  
  {% endpaginate %}
  
  </section>
  
  {% endblock %}
  
  ```
  
  my article listing module contains the usual things like {{ entry.title }} etc
  
  and pagination include is like so:
  
  ```
  {% if paginate %}
  
  {% set currentPage = paginate.currentPage %}
  {% set startPage = currentPage - 2 %}
  {% set endPage = currentPage + 2 %}
  {% if query is defined %}
  {% set queryString = "?q=" ~ query %}
  {% endif %}
  
  {% if paginate.totalPages > 1 %}
  <nav class="pagination" role="navigation">
  
      <ol class="pagination__list">
  
          {% if paginate.prevUrl %}
          <li class="pagination__item">
              <a class="btn  btn-2  btn-2a" href="{{ paginate.prevUrl }}{% if queryString is defined %}{{ queryString }}{% endif %}">
                  &larr;
                  <span class="visuallyhidden">Previous Page</span>
              </a>
          </li>
          {% endif %}
          {% for i in startPage..endPage %}
          {% if paginate.getPageUrl( i ) %}
          {% if i != currentPage %}
  
          <li class="pagination__item">
              <a class="btn  btn-2  btn-2a" href="{{ paginate.getPageUrl( i ) }}{% if queryString is defined %}{{ queryString }}{% endif %}">
                  <span class="visuallyhidden">Page </span>{{ i }}
              </a>
          </li>
  
          {% else %}
  
          <li class="pagination__item btn  -current">
              <span class="visuallyhidden">Current Page </span>{{ i }}
          </li>
  
          {% endif %}
      </li>
      {% endif %}
      {% endfor %}
  
      {% if paginate.nextUrl %}
      <li class="pagination__item">
          <a class="btn  btn-2  btn-2a" href="{{ paginate.nextUrl }}{% if queryString is defined %}{{ queryString }}{% endif %}">
              <span class="visuallyhidden">Next Page</span>
              &rarr;
          </a>
      </li>
      {% endif %}
  
  </ol>
  
  </nav>
  {% endif %}
  
  {% endif %}
  
  ```
  
  
  ---
  
  ### Answer by username_0 on 2015-05-27. Score: 0
  
  My category field was inside a Matrix field.
  
  These links helped with the twig logic:
  
  [Is it possible to have category listing page of entries if the category is defined within a matrix block inside said entries?](https://craftcms.stackexchange.com/questions/4830/is-it-possible-to-have-category-listing-page-of-entries-if-the-category-is-defin?rq=1)
  
  [Find entries that have a category selected from a category field within a matrix block](https://craftcms.stackexchange.com/questions/8463/find-entries-that-have-a-category-selected-from-a-category-field-within-a-matrix)
  
  
  ---
  
  