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.

wordpressrandomposts thumb Wordpress Random Posts With Custom Code

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.

share on twitter

Comments

  1. S.Pradeep Kumar says:

    I can’t find single.php file in my blog’s theme !

    I use StudioPress Church theme ! ^^

  2. Harsh Agrawal says:

    Pradeep I guess thats a premium theme , you need to check with the theme support forum.

  3. Venkatesh says:

    Can you give CSS code for this

Leave a Reply

© 2009-2011 ThemePremium · All Rights Reserved
A threeroutes media Publication