Tutorials
How to show blog posts changing every time after refreshing the page in non-wordpress website?

I have made a page in non-wordpress website which is showing the post from blog of wordpress website, it is working properly. I have added some PHP code in my page. Now I want that every time I refresh the page it will show different different post every time.

<?php 
  define('WP_USE_THEMES', false);
  require('blog/wp-load.php');
  query_posts('showposts=4');
?>

<ul style="margin-top:0px">

<?php while (have_posts()): the_post(); ?>
 <li style="border: 1px solid #edf4fc;margin-bottom:30px">
<div class="img-hover-zoom">
  <a target="_blank" href="<?php the_permalink(); ?>"><p>
  <?php
    if ( has_post_thumbnail() ) {
      the_post_thumbnail();
    }
  ?>
 </p>
 <div class="content">
 <h4 style="font-size:18px;"><?php the_title(); ?></h4>

</div>
</a></div>
 </li>

<?php endwhile; ?>
</ul>
I have made a page in non-wordpress website which is showing the post from blog of wordpress website, it is working properly. I have added some PHP code in my page. Now I want that every time I refresh the page it will show different different post every time. ```` &lt;?php define(&#039;WP_USE_THEMES&#039;, false); require(&#039;blog/wp-load.php&#039;); query_posts(&#039;showposts=4&#039;); ?&gt; &lt;ul style=&quot;margin-top:0px&quot;&gt; &lt;?php while (have_posts()): the_post(); ?&gt; &lt;li style=&quot;border: 1px solid #edf4fc;margin-bottom:30px&quot;&gt; &lt;div class=&quot;img-hover-zoom&quot;&gt; &lt;a target=&quot;_blank&quot; href=&quot;&lt;?php the_permalink(); ?&gt;&quot;&gt;&lt;p&gt; &lt;?php if ( has_post_thumbnail() ) { the_post_thumbnail(); } ?&gt; &lt;/p&gt; &lt;div class=&quot;content&quot;&gt; &lt;h4 style=&quot;font-size:18px;&quot;&gt;&lt;?php the_title(); ?&gt;&lt;/h4&gt; &lt;/div&gt; &lt;/a&gt;&lt;/div&gt; &lt;/li&gt; &lt;?php endwhile; ?&gt; &lt;/ul&gt; ````
73
0
2
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft