2016-03-05 5 views
0

Попытка заказать некоторые сообщения, которые отображаются на одной странице персонализированного типа сообщений со случайным, но они не являются случайными вообще. :/WP_Query orderby 'rand' не работает

<?php 
// Grab the taxonomy term slug for the current post 
$terms = get_the_terms(get_the_ID(), 'category-staff'); 

if ($terms && ! is_wp_error($terms)) : 

    $draught_links = array(); 

    foreach ($terms as $term) { 
     $draught_links[] = $term->slug; 
    } 

    $on_draught = join(", ", $draught_links); 
    ?> 

    <div class="container hidden-xs"> 
     <div class="row"> 
      <div class="col-sm-12"> 
       <hr /> 
       <h3 class="text-center">Other People At Our Great Resort</h3> 
      </div> 
     </div> 
     <div class="row"> 
      <div class="col-sm-12 col-lg-10 col-lg-offset-1"> 
       <div class="row staff-list"> 
        <?php 
         // WP_Query arguments 
         $args2 = array (
          'post_type'    => 'staff', 
          'tax_query'    => array(
           array(
            'taxonomy' => 'category-staff', 
            'field' => 'slug', 
            'terms' => $on_draught, 
           ), 
          ), 
          'nopaging'    => false, 
          'posts_per_page'   => '4', 
          'order'     => 'DESC', 
          'orderby'    => 'rand', 
         ); 


         // The Query 
         $query2 = new WP_Query($args2); 

         // The Loop 
         if ($query2->have_posts()) { 
          while ($query2->have_posts()) { 
           $query2->the_post(); ?> 

           <div class="staff staff-other col-sm-3 text-center"> 
            <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> 
             <?php echo get_the_post_thumbnail($_post->ID, 'large', array('class' => 'img-responsive img-circle img-staff')); ?> 
             <h4><?php the_title(); ?></h4> 
             <?php if (get_field('staff_job')) { ?> 
              <p><?php the_field('staff_job'); ?></p> 
             <?php } ?> 
            </a> 
           </div> 

          <?php } 
         } else { ?> 

         <?php } 

         // Restore original Post Data 
         wp_reset_postdata(); ?> 

       </div> 
      </div> 
     </div> 
    </div> 


<?php endif; // terms if statement ?> 

ответ

3

Оказывается, это как-то связано с WPEngine. Они отключают rand() с сервера, и это должно быть enabled manually.