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.


Here is WordPress Random Posts Custom code

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

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

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