Title: Random
Last modified: August 20, 2016

---

# Random

 *  [richwalker](https://wordpress.org/support/users/richwalker/)
 * (@richwalker)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/random-1/)
 * Hi
 * I am trying to make my posts in a child category show in a random order. I have
   this query post below but this only works for the category “The Category”. How
   do i do it for all my categories?
 * <?php
 * query_posts(array(
    ‘orderby’ => ‘rand’, ‘category_name’ => ‘The Category’ ));
   if (have_posts()) : while (have_posts()) : the_post(); ?>
 * Thanks

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

 *  [deepbevel](https://wordpress.org/support/users/deepbevel/)
 * (@deepbevel)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/random-1/#post-3244480)
 * try removing
 *     ```
       'category_name' => 'The Category'
       ```
   
 * from the array.
    just remember to remove the comma from the last argument in 
   the array, which in your case there’s only one left,so no comma.
 *     ```
       <?php
   
       query_posts(array(
        'orderby' => 'rand'
        ));
        if (have_posts()) : while (have_posts()) : the_post();
        ?>
       ```
   
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/random-1/#post-3244482)
 * > my posts in a child category
 * or
 * > for all my categories
 * which is it?
 *  Thread Starter [richwalker](https://wordpress.org/support/users/richwalker/)
 * (@richwalker)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/random-1/#post-3244484)
 * Sorry its a child category

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

The topic ‘Random’ is closed to new replies.

## Tags

 * [category](https://wordpress.org/support/topic-tag/category/)
 * [child category](https://wordpress.org/support/topic-tag/child-category/)
 * [post loop](https://wordpress.org/support/topic-tag/post-loop/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 3 participants
 * Last reply from: [richwalker](https://wordpress.org/support/users/richwalker/)
 * Last activity: [13 years, 6 months ago](https://wordpress.org/support/topic/random-1/#post-3244484)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
