title: Show random post in Wordpress and update content without refreshing page
body: <p>I'm building a Wordpress website where I need to display a random post (via WP_Query) and reload its content with a click of a button without refreshing the whole page.</p>
  <p>This is my HTML</p>
  <pre><code>&lt;div id=&quot;randompost&quot;&gt;&lt;/div&gt;
  &lt;button type=&quot;button&quot; id=&quot;reloadpost&quot;&gt;Reload post&lt;/button&gt;
  </code></pre>
  <p>And this is my WP_Query</p>
  <pre><code>&lt;?php
  
      $args = array(
          'post_type' =&gt; 'post',
          'post_status' =&gt; 'publish',
          'posts_per_page' =&gt; 1,
          'orderby' =&gt; 'rand',
      );
  
      $arr_posts = new WP_Query( $args );
          if ( $arr_posts-&gt;have_posts() ) : while ( $arr_posts-&gt;have_posts() ) : $arr_posts-&gt;the_post(); ?&gt;
  
                  &lt;h2&gt;&lt;?php the_title();?&gt;&lt;/h2&gt;
                  &lt;p&gt;&lt;?php the_content();?&gt;&lt;/p&gt;
  
      &lt;?php endwhile; endif; ?&gt;
  </code></pre>
  <p>I've read online about AJAX but I'm not that great at JS development and I could't find a way to make it work.</p>