title: Custom Post Type 'single-custom.php' next and previous links stuck in loop
body: <p>I've got a custom post type in Wordpress called 'cases'. For the single page I've created a single-case.php, which all works fined but one thing:</p>
  
  <p>Right outside the While loop I'm trying to have a 'Next' and 'Previous' link, like so:</p>
  
  <pre><code>&lt;?php next_post_link('%link', 'next item &amp;gt;') ?&gt;
  &lt;?php previous_post_link('%link', '&amp;lt; previous item') ?&gt;
  </code></pre>
  
  <p>But they get stuck in a loop. Once it reaches a certain article Wordpress gets stuck and loops the same two articles over and over.</p>
  
  <p>Here's the full (stripped down) template:</p>
  
  <pre><code>... Header ...
  &lt;?php while (have_posts()) : the_post(); ?&gt;
      &lt;div class="row content"&gt;
          &lt;div class="span4"&gt;
          &lt;?php if(count($aImages)) : ?&gt;
              &lt;?php foreach($aImages as $aImage) : ?&gt;
                  ....
              &lt;?php endforeach; ?&gt;
          &lt;?php endif; ?&gt;
          &lt;/div&gt;
  
          &lt;div class="span7"&gt;
              &lt;div class="case-title"&gt;&lt;?php the_title();?&gt;&lt;/div&gt;
              &lt;?php the_content(); ?&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;?php endwhile; ?&gt;
  ... Footer ...
  
  &lt;div class="next-posts pull-right"&gt;&lt;?php next_post_link('%link', 'volgend item &amp;gt;') ?&gt;&lt;/div&gt;
  &lt;div class="prev-posts pull-left"&gt;&lt;?php previous_post_link('%link', '&amp;lt; vorig item') ?&gt;&lt;/div&gt;
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>For some reason this fixes my issue:</p>
  
  <pre><code>&lt;div class="prev-posts pull-left"&gt;
      &lt;?php
      $prev_post = get_previous_post();
      if($prev_post) {
         $prev_title = strip_tags(str_replace('"', '', $prev_post-&gt;post_title));
         echo "\t" . '&lt;a rel="prev" href="' . get_permalink($prev_post-&gt;ID) . '" title="' . $prev_title. '" class=" "&gt;&lt;strong&gt;&lt;&lt;&lt; &amp;quot;'. $prev_title . '&amp;quot;&lt;/strong&gt;&lt;/a&gt;' . "\n";
                      }
      ?&gt;
      &lt;/div&gt;
  
      &lt;div class="next-posts pull-right"&gt;
      &lt;?
      $next_post = get_next_post();
      if($next_post) {
         $next_title = strip_tags(str_replace('"', '', $next_post-&gt;post_title));
         echo "\t" . '&lt;a rel="next" href="' . get_permalink($next_post-&gt;ID) . '" title="' . $next_title. '" class=" "&gt;&lt;strong&gt;&amp;quot;'. $next_title . '&amp;quot; &gt;&gt;&gt;&lt;/strong&gt;&lt;/a&gt;' . "\n";
                      }
      ?&gt;
      &lt;/div&gt;
  </code></pre>