WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I currently have TWO subpages under parent page ID 43. Client testimonials.. Anyway. I have the random order thing in the query $args but the order never changes. What could I be missing?

  'post_parent' => 43,
  'post_type' => 'page',
  'post_status' => 'publish',
  'posts_per_page' => 2, 
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
    while ($my_query->have_posts()) : $my_query->the_post();
    <h4><? echo get_post_meta($post->ID,'subtitle', true);?></h4>
    <p><? echo get_the_excerpt(); ?></p>
wp_reset_query();  // Restore global post data stomped by the_post().
share|improve this question
Your code looks correct, and i have tested it on my theme and it worked, but when you have rand on 2 post there is a big chance that the same post is gona show after it self again. Try to refresh the page a couple of times. And a saw that you are using php shorthand, you should change that to full PHP tags: codex.wordpress.org/… – Pontus Abrahamsson Jul 4 '12 at 21:48
Why did you call wp_reset_query? This implies that you used query_posts prior to this call, which would be bad. If you're using WP_Query, you want to call wp_reset_postdata instead. – Tom J Nowell Dec 12 '14 at 0:18

Turns out the "Custom Page Order" plugin was causing the randomization error... or rather, not allowing any randomization as it overrides it completely. Disabled the plug-in.

Whenever I need to change orders, I can enable the plugin, shuffle pages around, and then disable. But the need for this is decreasing more and more as we now have custom menu options in Wordpress.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.