Answers.Body: <p>I'm going to assume your project section is named <code>projects</code>, if it's not, replace it with you section name. </p>
  
  <p>Try this:</p>
  
  <pre><code>{% if nextEntry %}
      {% set nextEntryUrl = nextEntry.url %}
  {% else %}
      {% set firstEntry = craft.entries.section('projects').first() %}
      {% set nextEntryUrl = firstEntry.url %}
  {% endif %}
  
  {% if prevEntry %}
      {% set prevEntryUrl = prevEntry.url %}
  {% else %}
      {% set lastEntry = craft.entries.section('projects').last() %}
      {% set prevEntryUrl = lastEntry.url %}
  {% endif %}
  
  &lt;a href="{{ prevEntryUrl }}"&gt;Prev Project&lt;/a&gt;
  &lt;a href="{{ nextEntryUrl }}"&gt;Next Project&lt;/a&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-04T22:20:24.123Z
Answers.LastActivityDate: 2015-07-04T22:20:24.123Z
Answers.UserDisplayName: André Elvan
Answers.Body: <p>Could you do something like (untested)</p>
  
  <pre><code>{% set nextUrl = nextEntry is defined and nextEntry ? nextEntry.url : url('portfolio/root') %}
  &lt;a href="{{ nextUrl }}"&gt;Next page&lt;/a&gt;
  </code></pre>
  
  <p>Or, for probably better usability </p>
  
  <pre><code> {% if nextEntry %}
    &lt;a href="{{ nextEntry.url }}"&gt;Next Project&lt;/a&gt;
   {% else %}
     &lt;a href="{{ url('portfolio/root') }}"&gt;back to start&lt;/a&gt;
   {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-04T08:27:56.250Z
Answers.LastActivityDate: 2015-07-04T08:27:56.250Z
Answers.UserDisplayName: Alec Ritson
Body: <p>I've got a basic portfolio website which has "prev project" and "next project" buttons on each entry detail page. I'd like for when you reach the last project for the "next project" button to simply link back to the first instead of simply not appearing at all.</p>
  
  <p>Any idea how this could be done? Thanks so much in advance.</p>
  
  <pre><code> {% if nextEntry %}&lt;a href="{{ nextEntry.url }}"&gt;Prev Project&lt;/a&gt;{% endif %}
   {% if prevEntry %}&lt;a href="{{ prevEntry.url }}"&gt;Next Project&lt;/a&gt;{% endif %}
  </code></pre>
  
Tags: <entries>
Title: How to make next/prev links for entries circular/endless
ThreadText: # How to make next/prev links for entries circular/endless
  
  (Asked by: username_0 on 2015-07-04)
  
  I've got a basic portfolio website which has "prev project" and "next project" buttons on each entry detail page. I'd like for when you reach the last project for the "next project" button to simply link back to the first instead of simply not appearing at all.
  
  Any idea how this could be done? Thanks so much in advance.
  
  ```
   {% if nextEntry %}<a href="{{ nextEntry.url }}">Prev Project</a>{% endif %}
   {% if prevEntry %}<a href="{{ prevEntry.url }}">Next Project</a>{% endif %}
  
  ```
  
  **Tags:** entries
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2015-07-04. Score: 7
  
  I'm going to assume your project section is named `projects`, if it's not, replace it with you section name.
  
  Try this:
  
  ```
  {% if nextEntry %}
      {% set nextEntryUrl = nextEntry.url %}
  {% else %}
      {% set firstEntry = craft.entries.section('projects').first() %}
      {% set nextEntryUrl = firstEntry.url %}
  {% endif %}
  
  {% if prevEntry %}
      {% set prevEntryUrl = prevEntry.url %}
  {% else %}
      {% set lastEntry = craft.entries.section('projects').last() %}
      {% set prevEntryUrl = lastEntry.url %}
  {% endif %}
  
  <a href="{{ prevEntryUrl }}">Prev Project</a>
  <a href="{{ nextEntryUrl }}">Next Project</a>
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2015-07-04. Score: 2
  
  Could you do something like (untested)
  
  ```
  {% set nextUrl = nextEntry is defined and nextEntry ? nextEntry.url : url('portfolio/root') %}
  <a href="{{ nextUrl }}">Next page</a>
  
  ```
  
  Or, for probably better usability
  
  ```
   {% if nextEntry %}
    <a href="{{ nextEntry.url }}">Next Project</a>
   {% else %}
     <a href="{{ url('portfolio/root') }}">back to start</a>
   {% endif %}
  
  ```
  
  
  ---
  
  