WordPress Random Posts With Custom Code

WordPress is full of custom code which can use to get rid of lots of WordPress plugins.

One such plugin is Random posts plugin, but those who are familiar with coding which is not tough to implement. You can show random post below posts using this custom code.

wordpress-random-posts

Here is WordPress Random Posts Custom code

<ul>
  <li>
    <h2>Random Posts</h2>
    <ul>
      <?php
 $rand_posts = get_posts('numberposts=5&orderby=rand');
 foreach( $rand_posts as $post ) :
 ?>
      <li><a href="<?php the_permalink(); ?>">
        <?php the_title(); ?>
        </a></li>
      <?php endforeach; ?>
    </ul>
  </li>
</ul>

Add the code in your single.php file at your desire place.

Let me know if you face any problem or have any question.