Answers.Body: <p>Entirely possible I'm misunderstanding what you're looking for, but I think something like this should do it:</p>
  
  <pre><code>{% set entries = craft.entries.section('news').order('articleOrder desc').find() %}
  {% set matchCount = 0 %}
  
  {% for entry in entries %}
      {% if entry.currentYear2 == currentEdition.currentYear2 and currentEdition.currentMonth2 in entry.currentMonth2 and matchCount &lt;= 5 %}
          {% set matchCount = matchCount + 1 %}
          &lt;h2&gt;{{ entry.title }}&lt;/h2&gt;
      {% endif %}          
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-02T16:03:49.717Z
Answers.Text: Thank you, that worked perfect, and I would never have figured that out on my own!
Answers.UserDisplayName: afc
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-02T18:24:39.723Z
Answers.Text: I am having the same problem with offset(5) as opposed to limit. Issue is, that I am failing to understand how your fix works, therefor I can't make it happen for offset.
Answers.UserDisplayName: afc
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-02T00:28:06.813Z
Answers.LastActivityDate: 2017-07-02T00:28:06.813Z
Answers.UserDisplayName: Brad Bell
Body: <p>I've created two global variables which my content creator is going to use to turn off a bunch of articles and turn on a bunch more which a slight change in the Global.  I have a page where there is a limit of 5 of these articles.</p>
  
  <pre><code>{% set entries = craft.entries.section('news').order('articleOrder desc').limit(5).find() %}
  
  {% for entry in entries if entry.currentYear2 == currentEdition.currentYear2 and currentEdition.currentMonth2 in entry.currentMonth2 %}
      &lt;h2&gt;{{ entry.title }}&lt;/h2&gt;          
  {% endfor %}
  </code></pre>
  
  <p>The problem with this is that the conditional only gets 5 entries to compare, and not the entire bunch. I want to first run an if statement on all the entries, then let me do a for loop with a .limit(5). I am not sure how to go about this. A conditional combined with a for loop in the same statement did not work either.</p>
  
Tags: <conditional><forloop><limit>
Title: For loop, if statement, then limit
ThreadText: # For loop, if statement, then limit
  
  (Asked by: username_0 on 2017-07-01)
  
  I've created two global variables which my content creator is going to use to turn off a bunch of articles and turn on a bunch more which a slight change in the Global. I have a page where there is a limit of 5 of these articles.
  
  ```
  {% set entries = craft.entries.section('news').order('articleOrder desc').limit(5).find() %}
  
  {% for entry in entries if entry.currentYear2 == currentEdition.currentYear2 and currentEdition.currentMonth2 in entry.currentMonth2 %}
      <h2>{{ entry.title }}</h2>          
  {% endfor %}
  
  ```
  
  The problem with this is that the conditional only gets 5 entries to compare, and not the entire bunch. I want to first run an if statement on all the entries, then let me do a for loop with a .limit(5). I am not sure how to go about this. A conditional combined with a for loop in the same statement did not work either.
  
  **Tags:** conditional, forloop, limit
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-07-02. Score: 0 | Accepted answer
  
  Entirely possible I'm misunderstanding what you're looking for, but I think something like this should do it:
  
  ```
  {% set entries = craft.entries.section('news').order('articleOrder desc').find() %}
  {% set matchCount = 0 %}
  
  {% for entry in entries %}
      {% if entry.currentYear2 == currentEdition.currentYear2 and currentEdition.currentMonth2 in entry.currentMonth2 and matchCount <= 5 %}
          {% set matchCount = matchCount + 1 %}
          <h2>{{ entry.title }}</h2>
      {% endif %}          
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: Thank you, that worked perfect, and I would never have figured that out on my own!  
  > **username_0**: I am having the same problem with offset(5) as opposed to limit. Issue is, that I am failing to understand how your fix works, therefor I can't make it happen for offset.  
  
  ---
  
  