<p>I was missing: <code>{% set category = entry.workCategory%}</code></p>

CC BY-SA 3.0
2016-12-23T08:57:52.427Z
2016-12-23T18:24:49.683Z
2016-12-23T18:24:49.683Z
user2569
<p>When you are within your <code>nav</code> tag context, <code>category</code> definitely exists, even if you're using <code>include</code> for the first snippet you posted. If you're talking about the automatically pre-assigned variable for a single category's page, make sure the category group settings are still correct and that you are requesting the right URLs.</p>

CC BY-SA 3.0
2016-12-23T08:10:38.663Z
2016-12-23T08:10:38.663Z
carlcs
<p>I'm not sure what I've done, I had this working at the top of my entry.html template:</p>

<hr>

<pre><code>{% set params = craft.entries.section('ourWork').relatedTo(category) %}

{% set prevEntry = entry.getPrev(params) %}
{% set nextEntry = entry.getNext(params) %}

{% if prevEntry %}&lt;a href="{{ prevEntry.url }}"&gt;Previous&lt;/a&gt;{% endif %}
{% if nextEntry %}&lt;a href="{{ nextEntry.url }}"&gt;Next&lt;/a&gt;{% endif %}
</code></pre>

<p>For some reason I just get:
Variable "category" does not exist</p>

<p>The section name is correct and this does have a category field assigned.</p>

<p>my index template category part is:</p>

<pre><code>{# Projects
---------------------------------------------------------------------------#}
&lt;div class="banner projects"&gt;
&lt;div class="row"&gt;        
  &lt;ul class="no-bullet small-up-2 medium-up-3 large-up-4 large-centered"&gt; 
  {#
  Display catgeory nav 'ourWork'
  #}
    {% nav category in craft.categories.group('ourWork').level(1) %}         
      &lt;li class= "column"&gt;                        
          {# &lt;p&gt;{{ category.WorkCategoryDescription }}&lt;p&gt; #}                 
          &lt;a href="{{ category.url }}"&gt;&lt;img src="{{ category.categoryImageThumb.first.getUrl('categoryThumbnail') }}"&gt;&lt;/a&gt;             
          &lt;p&gt; &lt;a href="{{ category.url }}"&gt;{{ category.title }} &lt;/a&gt;&lt;p&gt;
      &lt;/li&gt;
    {% endnav %}
  &lt;/ul&gt;
&lt;/div&gt;
</code></pre>

<p></p>

CC BY-SA 3.0
2016-12-23T08:11:05.670Z
Can you explain how you use these two snippets of code together?
carlcs
<category>
Previous and next entries nav – within a categeory
# Previous and next entries nav – within a categeory

(Asked by: username_0 on 2016-12-22)

I'm not sure what I've done, I had this working at the top of my entry.html template:

{% set params = craft.entries.section('ourWork').relatedTo(category) %}

{% set prevEntry = entry.getPrev(params) %}
{% set nextEntry = entry.getNext(params) %}

{% if prevEntry %}Previous{% endif %}
{% if nextEntry %}Next{% endif %}

For some reason I just get:
Variable "category" does not exist
The section name is correct and this does have a category field assigned.
my index template category part is:
{# Projects
---------------------------------------------------------------------------#}

        
   
  {#
  Display catgeory nav 'ourWork'
  #}
    {% nav category in craft.categories.group('ourWork').level(1) %}         
                              
          {# {{ category.WorkCategoryDescription }} #}                 
                       
           {{ category.title }} 
      
    {% endnav %}

**Tags:** category
> **Comments:**
> **username_1**: Can you explain how you use these two snippets of code together?  

---

## 2 answers

### Answer by username_0 on 2016-12-23. Score: 1

I was missing: `{% set category = entry.workCategory%}`


---

### Answer by username_1 on 2016-12-23. Score: 1

When you are within your `nav` tag context, `category` definitely exists, even if you're using `include` for the first snippet you posted. If you're talking about the automatically pre-assigned variable for a single category's page, make sure the category group settings are still correct and that you are requesting the right URLs.


---

