title: Load wordpress loop in external php file, ajax loading posts
body: <p>Why does my loop always return "no posts" ? I've included all necessary files it seems. I'd like to use this page for ajax calls, but I cannot get it to work as a normal loop. If I use get_posts it works, but that's not what I need.</p>
  
  <p>So far I've:</p>
  
  <pre><code>&lt;?php
  /* Define these, So that WP functions work inside this file */
  define('WP_USE_THEMES', false);
  require('../../../wp-load.php');
  ?&gt;
  
  
  
  &lt;div id="container"&gt;
      &lt;?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?&gt;
      &lt;div class="movie"&gt;
          &lt;a href="&lt;?php the_permalink() ?&gt;"&gt;
              &lt;?php
                  if (has_post_thumbnail()) {the_post_thumbnail('homepage-preview');}
                  else {echo '&lt;img src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/default-poster.jpg" /&gt;';}
              ?&gt;
              &lt;p class="comments"&gt;&lt;?php comments_number('0 review','1 review','% reviews'); ?&gt;&lt;/p&gt;
              &lt;div class="description"&gt;
                  &lt;h2&gt;&lt;?php the_title(); ?&gt;&lt;/h2&gt;
                  &lt;?php the_excerpt(); ?&gt;
              &lt;/div&gt;
          &lt;/a&gt;
      &lt;/div&gt;
      &lt;?php endwhile; else: ?&gt;
          &lt;!-- No movies found --&gt;
      &lt;?php endif; ?&gt;
  &lt;/div&gt;&lt;!-- End #container --&gt;
  
  
  
  
  &lt;!-- pagination --&gt;
  &lt;nav id="nav-below"&gt;
  &lt;?php previous_posts_link('&lt;span id="prev_page"&gt;Previous Page&lt;/span&gt;'); ?&gt;
  &lt;?php next_posts_link('&lt;span id="next_page"&gt;Next Page&lt;/span&gt;'); ?&gt;
  &lt;/nav&gt;
  </code></pre>