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;font-weight:500;"><?php the_title(); ?></h4>

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

<?php endwhile; ?>
</ul>

Whatever is this doing?

Showing post from blog.

Modify the query to show random posts.

Yes it is working now…

1 Like