2016-12-19 12 views
0

WordPressサイトで[拡張カスタムフィールド]プラグインを使用しています。私はページごとに表示する25以上の引用符を持つリピーターフィールドを持っています。各ページには一意の引用符があります。PHP配列ランダム変数がページリフレッシュ時に切り替わらない

私が現在ログオンしているときと同じように、25のプールから1つのランダムな見積もりを引き出すコードがあります。ログアウトすると、1つのランダムな見積もりが引かれますが、それは私がログインしていたときにありませんようにページ上の別の一つはリフレッシュ

私はここからこのランダムな行のコードを使用しています:。 https://gist.github.com/wesrice/1924934

<?php  
     if (is_singular('post')) { 
      $repeater2 = get_field('quote_info', 11); 
      $random_rows2 = array_rand($repeater2, 1);   
       if(is_array($random_rows2)){ 
        foreach($random_rows2 as $random_row2){  
         echo '<div class="newquote">        
           <div class="newinnerwrapperquote">&quot;' . $repeater2[$random_row2]['bottom_quote_text'] . '&quot;</div>'; 
         echo '<div class="newquoteby">' . $repeater2[$random_row2]['bottom_quote_author'] . '</div></div>'; 
        } 
       } else {     

        echo '<div class="newquote">        
           <div class="newinnerwrapperquote">&quot;' . $repeater2[$random_rows2]['bottom_quote_text'] . '&quot;</div>'; 
        echo '<div class="newquoteby">' . $repeater2[$random_rows2]['bottom_quote_author'] . '</div></div>'; 
       } wp_reset_query(); 
     } else { 
      $repeater = get_field('quote_info');   
      $random_rows = array_rand($repeater, 1); 
      if(is_array($random_rows)){ 
       foreach($random_rows as $random_row){  
        echo '<div class="newquote">        
          <div class="newinnerwrapperquote">&quot;' . $repeater[$random_row]['bottom_quote_text'] . '&quot;</div>'; 
        echo '<div class="newquoteby">' . $repeater[$random_row]['bottom_quote_author'] . '</div></div>'; 
       } 
      } else {     

       echo '<div class="newquote">        
          <div class="newinnerwrapperquote">&quot;' . $repeater[$random_rows]['bottom_quote_text'] . '&quot;</div>'; 
       echo '<div class="newquoteby">' . $repeater[$random_rows]['bottom_quote_author'] . '</div></div>'; 
      } 

     } 

?> 

最初の文である場合、それはWordPressのポスト上にある場合ページではなくむしろ。私はこれをうまく説明してくれればと思う。

+1

ランダムな推測..キャッシング –

答えて

0

内部キャッシュプラグインが有効化されました。それをオフにして、ログインしていないときに動作します。

関連する問題