Wordpress Random Posts With Custom Code

by Themepremium on September 7, 2009

Thesis Theme

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.

Related posts:

  1. Generate thumbnails for All Wordpress blog posts at once
  2. Wordpress Plugin To Edit Posts And Comments Without Logging In
  3. Disable Wordpress Post revision Without Plugin
  4. Tutorial: How to Create Wordpress Plugins
  5. Buy me a Beer Wordpress Plugin for Making Money from your Posts

WooThemes - WordPress themes for everyone

{ 3 comments… read them below or add one }

S.Pradeep Kumar October 25, 2009 at 11:21 pm

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

I use StudioPress Church theme ! ^^

Reply

Harsh Agrawal November 11, 2009 at 5:37 am

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

Reply

Venkatesh April 9, 2010 at 4:42 pm

Can you give CSS code for this

Reply

Leave a Comment

Previous post:

Next post:

.