title: Refresh changes and new posts in wp query using ajax
body: <p>I am trying to make a page on wordpress, where all new posts and changes on existing posts will appaer automatically in the feed. The feed will reload every 5 second. </p>
  
  <p>In the code below i only got the records from the database, and every 5 second all the posts will be added again on the end. </p>
  
  <p>How can I check if the post is new or changed after last "get" from the database?</p>
  
  <p><strong>display.php</strong></p>
  
  <pre><code>&lt;?php include( '../../../../wp-load.php' ); // loads WordPress Environment ?&gt;
  &lt;?php
  $fivesdrafts = $wpdb-&gt;get_results( 
      "
      SELECT ID, post_title 
      FROM $wpdb-&gt;posts
      WHERE post_type = 'post' "
  );
  
  foreach ( $fivesdrafts as $fivesdraft ) 
  {
      echo $fivesdraft-&gt;post_title;
  }
  
  ?&gt;
  </code></pre>
  
  <p><strong>single.php</strong></p>
  
  <pre><code>&lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  setInterval(ajaxCall, 5000);
  
  function ajaxCall() {
      $.ajax({
              url: 'http://localhost:8888/wp-content/themes/wp-bootstrap-starter/inc/display.php',
              success: function(data) {
  
                  $('p').append(data);
              }
          });
  }
  
  &lt;/script&gt;
  
          &lt;section id="primary" class="content-area col-sm-12 col-lg-12"&gt;
              &lt;main id="main" class="site-main" role="main"&gt;
  
                  &lt;p&gt;&lt;/p&gt;
  
              &lt;/main&gt;&lt;!-- #main --&gt;
          &lt;/section&gt;&lt;!-- #primary --&gt;
  </code></pre>