Title: Problem with random post
Last modified: August 20, 2016

---

# Problem with random post

 *  [earthshaver](https://wordpress.org/support/users/earthshaver/)
 * (@earthshaver)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/problem-with-random-post/)
 * I’ve made a custom page-template to generate random post and re-direct users 
   into that post.
 *     ```
       <?php
       /**
        * Template Name: Random Post
        */
       ?>
   
       <?php
           query_posts('orderby=rand');
           while (have_posts()) {
               the_post();
               wp_redirect(get_permalink());
           }
       ?>
   
       <?php get_header(); ?>
       <?php get_footer(); ?>
       ```
   
 * It works well in localhost, but when I actually applied it on my site. I got 
   this warning while opening the page:
 * **Warning: Cannot modify header information – headers already sent by (output
   started at /home/admin1/public_html/wp-content/themes/bumi2013/template-random-
   post.php:7) in /home/admin1/public_html/wp-includes/pluggable.php on line 866**
 * Any idea how to solve this problem?

Viewing 1 replies (of 1 total)

 *  Thread Starter [earthshaver](https://wordpress.org/support/users/earthshaver/)
 * (@earthshaver)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/problem-with-random-post/#post-3140829)
 * Some people told me that turning-off other plug-ins might solve the problem. 
   I’ve tried it, but it doesn’t solve the problem.

Viewing 1 replies (of 1 total)

The topic ‘Problem with random post’ is closed to new replies.

## Tags

 * [custom page template](https://wordpress.org/support/topic-tag/custom-page-template/)

 * 1 reply
 * 1 participant
 * Last reply from: [earthshaver](https://wordpress.org/support/users/earthshaver/)
 * Last activity: [13 years, 7 months ago](https://wordpress.org/support/topic/problem-with-random-post/#post-3140829)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
