0
votes

I am using a while loop

while (have_posts()) : the_post();

to get all the post and displaying a page. How to randomise the post. But the problem is, in the page I am working on there is no sign of 'query'. Also I tried to use some solutions mentioned but no result.

1

1 Answers

0
votes

You can alter the main query with query_posts($args) this way:

// Alter the query
query_posts( 'orderby=RAND' );

while ( have_posts() ) : the_post();

    // Do your stuff inside the loop

endwhile;

// Reset the query
wp_reset_query();