Answers.Body: <p>Got it to work! I don't know why I made it so complicated in my head, but I ended up using the link id to match with the properties link.</p>
  
  <pre><code>{% nav link in menu.all %}
      &lt;li {% if craft.app.request.absoluteUrl == link.addentry[0].url %} class="active"{% endif %}&gt;
          &lt;a href="{{ link.addentry[0].url }}"&gt;{{ link.title }}{% if link.id == 15 %}&lt;span class="exposant"&gt;{% set totalListings = craft.entries.section('listings').total() %}{{ totalListings }}&lt;/span&gt;{% endif %}&lt;/a&gt;
      &lt;/li&gt;
  {% endnav %}
  </code></pre>
  
  <p>If someone can show me how to get it by slug that would be awesome! Thanks &amp; hope this will help someone in the future.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-18T08:58:46.523Z
Answers.Text: What do you mean with "get it by slug"? You can check the `link.uri` attribute for singles or the much better approach `entry.getType.handle`
Answers.UserDisplayName: Robin Schambach
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-18T02:14:54.030Z
Answers.LastActivityDate: 2018-03-18T02:14:54.030Z
Answers.UserDisplayName: mateostabio
Body: <p>I'm trying to achieve one pretty simple thing, but putting it into my dynamic nav is making it a little difficult. I want to have a little number of the total amount of entries in my channel "listings" and keep it on one of the links "Our Properties".</p>
  
  <p><a href="https://i.sstatic.net/QJV0Z.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/QJV0Z.png" alt="What the main Nav has to look like"></a></p>
  
  <p>I currently have this code that is displaying the total amount of entries</p>
  
  <pre><code>{% set totalListings = craft.entries.section('listings').total() %}
  {{ totalListings }}
  </code></pre>
  
  <p>How can I make this work: {% if link == "properties" single entry %} {{ totalListings}} {% endif %}</p>
  
  <pre><code>{% set menu = craft.entries.section('navigation') %}
  &lt;ul&gt; 
      {% nav link in menu.all %}
          &lt;li {% if craft.app.request.absoluteUrl == link.addentry[0].url %} class="active"{% endif %}&gt;
             &lt;a href="{{ link.addentry[0].url }}"&gt;{{ link.title }}&lt;/a&gt;
          &lt;/li&gt;
      {% endnav %}
  &lt;/ul&gt;
  </code></pre>
  
Tags: <conditional><navigation><forloop><entry-slug>
Title: Dynamic Navigation with Condition to check slug
ThreadText: # Dynamic Navigation with Condition to check slug
  
  (Asked by: username_0 on 2018-03-18)
  
  I'm trying to achieve one pretty simple thing, but putting it into my dynamic nav is making it a little difficult. I want to have a little number of the total amount of entries in my channel "listings" and keep it on one of the links "Our Properties".
  
  [![What the main Nav has to look like](https://i.sstatic.net/QJV0Z.png)](https://i.sstatic.net/QJV0Z.png)
  
  I currently have this code that is displaying the total amount of entries
  
  ```
  {% set totalListings = craft.entries.section('listings').total() %}
  {{ totalListings }}
  
  ```
  
  How can I make this work: {% if link == "properties" single entry %} {{ totalListings}} {% endif %}
  
  ```
  {% set menu = craft.entries.section('navigation') %}
  <ul> 
      {% nav link in menu.all %}
          <li {% if craft.app.request.absoluteUrl == link.addentry[0].url %} class="active"{% endif %}>
             <a href="{{ link.addentry[0].url }}">{{ link.title }}</a>
          </li>
      {% endnav %}
  </ul>
  
  ```
  
  **Tags:** conditional, navigation, forloop, entry-slug
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2018-03-18. Score: 1
  
  Got it to work! I don't know why I made it so complicated in my head, but I ended up using the link id to match with the properties link.
  
  ```
  {% nav link in menu.all %}
      <li {% if craft.app.request.absoluteUrl == link.addentry[0].url %} class="active"{% endif %}>
          <a href="{{ link.addentry[0].url }}">{{ link.title }}{% if link.id == 15 %}<span class="exposant">{% set totalListings = craft.entries.section('listings').total() %}{{ totalListings }}</span>{% endif %}</a>
      </li>
  {% endnav %}
  
  ```
  
  If someone can show me how to get it by slug that would be awesome! Thanks & hope this will help someone in the future.
  
  > **Comments:**
  > **username_1**: What do you mean with "get it by slug"? You can check the `link.uri` attribute for singles or the much better approach `entry.getType.handle`  
  
  ---
  
  