Answers.Body: <p>What you do, is this:</p>
  
  <ul>
  <li>Get 30 items from the database, ordered by showTime</li>
  <li>Then, you filter them with the if-attribute in the for-statement</li>
  </ul>
  
  <p>This means, that you could get anywhere from 0 to 30 results. What you want to do, is make sure the filtering happens within the element query. I did not test this (not sure about the time criteria part), but something like this should work:</p>
  
  <pre><code>{% for entry in craft.entries
      .section('shows')
      .order('showTime')
      .search('showDay:*' ~ now |date('N') ~ '*')
      .showTime('&gt;= ' ~ now |date('H:i'))
      .limit(3) %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-06T16:53:32.533Z
Answers.Text: Unfortunately moving the limitation to the end doesn't have an effect, weirdly more than 3 still display.
Answers.UserDisplayName: Tom Qwen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-06T16:56:45.593Z
Answers.Text: It’s not really about the position of the limit(), it’s about having the extra criteria in your query. You can set the limit to 3, if you do it this way.
Answers.UserDisplayName: Paul
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-06T16:57:52.397Z
Answers.Text: The order of criteria does not really matter.
Answers.UserDisplayName: Paul
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-06T17:07:09.617Z
Answers.Text: Okay, I've not used search yet so it's thrown me. 
  
  I'm being returned this Error Message...
  Arguments must be separated by a comma. Unexpected token "name" of value "N" ("punctuation" expected with value ",").
Answers.UserDisplayName: Tom Qwen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-06T17:35:25.483Z
Answers.Text: Just a little Syntax error `search('showDay:"*"' ~ now |date('N') ~ '"*"')` I would suggest you to read the docs about how to search entries in craft
Answers.UserDisplayName: Robin Schambach
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-08T15:02:05.073Z
Answers.Text: Thanks I'd have never caught that, I'll read up on searches. Thanks Paul!
Answers.UserDisplayName: Tom Qwen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-06T14:18:03.703Z
Answers.LastActivityDate: 2017-11-06T17:58:23.640Z
Answers.LastEditDate: 2017-11-06T17:58:23.640Z
Answers.UserDisplayName: Paul
Body: <p>I'm working on a new website for my student radio station but I've stumbled into a few key bugs which are stopping us from advertising the new site. </p>
  
  <p>It's live right now over on Stormfm.com, you'll be able to see the problems for yourselves there. </p>
  
  <p>The up coming shows section is supposed to display the next 3 shows, however there's a bug with it's limit, to get the section to display at least 3 shows I had to raise the limit to 30, this then means up to 30 shows display. I've copied the code below.</p>
  
  <pre class="lang-html prettyprint-override"><code>{% for entry in craft.entries.section('shows').order('showTime').limit(30)
      if entry.showDay.contains('now'|date('N')) and entry.showTime &gt; 'now'|date('H:i') %}
  
  
    &lt;div class="flex-box mobile"&gt;
      &lt;a class="link-block w-inline-block" href="{{ entry.url }}"&gt;
        &lt;div class="up-coming-image" style="background-image:url({{ entry.showImage[0].url }}); background-size:cover;" &gt;
          &lt;div class="up-coming-fade" data-ix="fademouse"&gt;
            &lt;div&gt;{{ entry.showTime }} - {{ entry.showLength }}&lt;/div&gt;
            &lt;h4 class="up-coming-heading"&gt;{{ entry.Title }}&lt;/h4&gt;
            &lt;div&gt;With {{ entry.hostname.first().title }} &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="image-btn"&gt;&amp;gt;&lt;/div&gt;
        &lt;/div&gt;
      &lt;/a&gt;
    &lt;/div&gt;
  
  {% endfor %}
  </code></pre>
  
  <p>Also I want to display what the current show on air is, originally I was going to use a similar code to the above, limit it to 1 and have it minus an hour but I can't seem to work out how to do that. For the short term I can flip the greater than to less than, however this then displays only the closest show and I can't else out into a default display if nothing is currently timetabled as on air. </p>
  
  <p>I hope this all makes sense and would appreciate any help you might be able to provide! </p>
  
  <p>Tom</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-11-06T13:56:22.407Z
Comments.Text: I've made some changes on the websites, by limiting to 17 I can display 4 up coming shows, sort term thats great but I have a feeling its just going to throw up glitches later, any advice on the proper way to do this?
Comments.UserDisplayName: Tom Qwen
Tags: <limit><bug>
Title: Get next 3 upcoming entries
ThreadText: # Get next 3 upcoming entries
  
  (Asked by: username_0 on 2017-11-06)
  
  I'm working on a new website for my student radio station but I've stumbled into a few key bugs which are stopping us from advertising the new site.
  
  It's live right now over on Stormfm.com, you'll be able to see the problems for yourselves there.
  
  The up coming shows section is supposed to display the next 3 shows, however there's a bug with it's limit, to get the section to display at least 3 shows I had to raise the limit to 30, this then means up to 30 shows display. I've copied the code below.
  
  ```html
  {% for entry in craft.entries.section('shows').order('showTime').limit(30)
      if entry.showDay.contains('now'|date('N')) and entry.showTime > 'now'|date('H:i') %}
  
    <div class="flex-box mobile">
      <a class="link-block w-inline-block" href="{{ entry.url }}">
        <div class="up-coming-image" style="background-image:url({{ entry.showImage[0].url }}); background-size:cover;" >
          <div class="up-coming-fade" data-ix="fademouse">
            <div>{{ entry.showTime }} - {{ entry.showLength }}</div>
            <h4 class="up-coming-heading">{{ entry.Title }}</h4>
            <div>With {{ entry.hostname.first().title }} </div>
          </div>
          <div class="image-btn">&gt;</div>
        </div>
      </a>
    </div>
  
  {% endfor %}
  
  ```
  
  Also I want to display what the current show on air is, originally I was going to use a similar code to the above, limit it to 1 and have it minus an hour but I can't seem to work out how to do that. For the short term I can flip the greater than to less than, however this then displays only the closest show and I can't else out into a default display if nothing is currently timetabled as on air.
  
  I hope this all makes sense and would appreciate any help you might be able to provide!
  
  Tom
  
  **Tags:** limit, bug
  
  > **Comments:**
  > **username_0**: I've made some changes on the websites, by limiting to 17 I can display 4 up coming shows, sort term thats great but I have a feeling its just going to throw up glitches later, any advice on the proper way to do this?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-11-06. Score: 4 | Accepted answer
  
  What you do, is this:
  
  * Get 30 items from the database, ordered by showTime
  * Then, you filter them with the if-attribute in the for-statement
  
  This means, that you could get anywhere from 0 to 30 results. What you want to do, is make sure the filtering happens within the element query. I did not test this (not sure about the time criteria part), but something like this should work:
  
  ```
  {% for entry in craft.entries
      .section('shows')
      .order('showTime')
      .search('showDay:*' ~ now |date('N') ~ '*')
      .showTime('>= ' ~ now |date('H:i'))
      .limit(3) %}
  
  ```
  
  > **Comments:**
  > **username_0**: Unfortunately moving the limitation to the end doesn't have an effect, weirdly more than 3 still display.  
  > **username_1**: It’s not really about the position of the limit(), it’s about having the extra criteria in your query. You can set the limit to 3, if you do it this way.  
  > **username_1**: The order of criteria does not really matter.  
  > **username_0**: Okay, I've not used search yet so it's thrown me.   I'm being returned this Error Message... Arguments must be separated by a comma. Unexpected token "name" of value "N" ("punctuation" expected with value ",").  
  > **username_2**: Just a little Syntax error `search('showDay:"*"' ~ now |date('N') ~ '"*"')` I would suggest you to read the docs about how to search entries in craft  
  > **username_0**: Thanks I'd have never caught that, I'll read up on searches. Thanks username_1!  
  
  ---
  
  