WordPress.org

Ready to get started?Download WordPress

Forums

Problem with random post (2 posts)

  1. earthshaver
    Member
    Posted 1 year ago #

    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?

  2. earthshaver
    Member
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic