Title: Random post from database
Last modified: August 19, 2016

---

# Random post from database

 *  Resolved [henkmsncam](https://wordpress.org/support/users/henkmsncam/)
 * (@henkmsncam)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/radom-post-from-database/)
 * Hi,
 * I searched a lot but I cant seem to find the right solution. What I would like
   is to show complete random full posts to each visitor from my database. Not only
   the title (I did see plugins for that)
 * I am using the following code right now (in index.php)
 * <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class=”
   entry”> <h1 id=”post-<?php the_ID(); ?>”>” rel=”bookmark”><?php the_title(); ?
   ></h1> <div align=”left”><?php the_content(‘Read the rest of this entry »’); ?
   ></div> <div class=”info”> <p class=”infoleft”><?php if ( the_tags(‘Tagged with‘,‘,‘))?
   ></p> <p class=”inforight”> <?php edit_post_link(‘Edit’); ?></p> <br clear=”all”/
   > </div> <?php if ( comments_open() ) comments_template(); ?> </div> <?php endwhile;
   else: ?> <div class=”entry”> <p><b>Sorry, but you are looking for something that
   isn’t here.</b></p> </div> <?php endif; ?>
 * thanks!

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/radom-post-from-database/#post-874137)
 * Look at the **orderby=rand** parameter in the [template tag](http://codex.wordpress.org/Template_Tags),
   [query_posts()](http://codex.wordpress.org/Template_Tags/query_posts).
 *  Thread Starter [henkmsncam](https://wordpress.org/support/users/henkmsncam/)
 * (@henkmsncam)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/radom-post-from-database/#post-874397)
 * Great thx. I added
 * <?php
    if (is_home()) { query_posts(‘orderby=rand’); } ?>
 * before the loop and it works!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Random post from database’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [henkmsncam](https://wordpress.org/support/users/henkmsncam/)
 * Last activity: [17 years, 8 months ago](https://wordpress.org/support/topic/radom-post-from-database/#post-874397)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
