Title: Show posts in random order
Last modified: August 20, 2016

---

# Show posts in random order

 *  [ksgboy2](https://wordpress.org/support/users/ksgboy2/)
 * (@ksgboy2)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/show-posts-in-random-order/)
 * I read few posts but not working for me
 * When i click on category i would like to see posts in random order not from latest
   post to first post.
 * I don’t want random post i want random order
 * If you’ll send me some code please let me know where i have to add this code
 * Thanks for any help

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

 *  [RichardWPG](https://wordpress.org/support/users/richardwpg/)
 * (@richardwpg)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/show-posts-in-random-order/#post-2635340)
 * [http://codex.wordpress.org/Template_Tags/get_posts](http://codex.wordpress.org/Template_Tags/get_posts)
 *  [DanBerlin](https://wordpress.org/support/users/danberlin/)
 * (@danberlin)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/show-posts-in-random-order/#post-2635353)
 * Can any one elaborate on this? i.e. put in simple terms for a non programmer?
   I would like to randomize the post on the homepage is there any easy way of doing
   this?
 *  Thread Starter [ksgboy2](https://wordpress.org/support/users/ksgboy2/)
 * (@ksgboy2)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/show-posts-in-random-order/#post-2635433)
 * I’m using this
 *     ```
       <?php
       $args = array( 'orderby' => 'rand' );
       $lastposts = get_posts( $args );
       foreach($lastposts as $post) : setup_postdata($post); ?>
       	<h2><a>"><?php the_title(); ?></a></h2>
       	<?php the_content(); ?>
       <?php endforeach; ?>
       ```
   
 * _[Please post code or markup snippets between backticks or use the code button.]_
 * And on Home page everything is ok
 * But on categories showing posts in random order but not from current category
   but from all posts
 *  [philtyler](https://wordpress.org/support/users/philtyler/)
 * (@philtyler)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/show-posts-in-random-order/#post-2635523)
 * Where do you put that above code? I have a very simple site up with only 10 posts.
   I would like the 10 posts to always be random.

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

The topic ‘Show posts in random order’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 4 participants
 * Last reply from: [philtyler](https://wordpress.org/support/users/philtyler/)
 * Last activity: [13 years, 5 months ago](https://wordpress.org/support/topic/show-posts-in-random-order/#post-2635523)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
