• Resolved pagol

    (@pagol)


    recently i found orderby=rand not work. even my old wordpress theme which was work before after update wordprss not work any more. i tried many way to but seems all same.

    <?php $my_query = new WP_Query('category_name=products&orderby=rand&showposts=5'); ?>
    
          <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
    
          <li>
    
            <a href="<?php
        $url = get_post_meta($post->ID, 'productURL', true); 
    
    	if ($url) {
    	    echo "$url";
    	}
    ?>"  target="_blank"><?php  the_post_thumbnail() ?>
    
            <h2>
    
              <?php the_title(); ?>
    
            </h2>
    
           </a></li>
    
          <?php endwhile; ?>

    above simple random post it was work before fine now don’t

    <?php $testo_query = new WP_Query('category_name=testimonials&orderby=rand&showposts=1'); ?>
          <?php while ($testo_query->have_posts()) : $testo_query->the_post(); ?>
          <?php the_content(); ?>
          <div class="author">
            <?php the_title(); ?>
            <br>
            <?php the_field('position'); ?>
          </div>
          <?php endwhile; ?>

    none is work.

    guys any idea why not work.. how to make it work .

Viewing 1 replies (of 1 total)
  • Moderator Bet Hannon

    (@bethannon1)

    You marked this resolved. Glad you got it figured out! Care to leave some clues about how you did this, to perhaps help someone else who has the same question?

Viewing 1 replies (of 1 total)
  • The topic ‘Order by random not work wordpress anymore’ is closed to new replies.