• I’ve got this in my archive.php… but how do i randomise the posts?

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <?php the_title();?>
    <?php endwhile; else: ?>

    Thanks heaps!!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Try changing this:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    to this:

    <?php global $query_string;
    query_posts($query_string . '&orderby=rand');
    if (have_posts()) : while (have_posts()) : the_post(); ?>

    You should note that randomizing will interfere with pagination. Pagination really doesn’t make sense with random retrieval.

    Thread Starter Pete

    (@perthmetro)

    Thanks i’ll give it a go.

    Thread Starter Pete

    (@perthmetro)

    This worked

    <?php $posts = query_posts($query_string . '&orderby=rand'); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Random posts in archive.php?’ is closed to new replies.