0

私は証言の 1 つのランダムな行を取得しようとしていますが、その行には sitewide_displayサブ フィールドの「真」の値が含まれている必要があります。

私の人生ではこれを機能させることはできません。これは、リフレッシュ時に感じられる結果が得られるだけです。

このような while ループ内でサブフィールド値 (sitewide_display) の条件を使用すると、何らかの競合が発生しますか?

<?php $rows = get_field('testimonials' ); // get all the rows ?>
    <?php if( $rows ) : // if there are rows, continue ?>  
         <?php while( has_sub_field('testimonials') ) : ?>   
            <?php if( get_sub_field('sitewide_display')): ?> 
                <?php $rand_row = $rows[ array_rand( $rows ) ]; // get the first row ?>
                <?php  $rand_row_testimonial_name = $rand_row['testimonial_name' ]; // get the sub field value  ?>
                <?php echo $rand_row_testimonial_name; ?>            
            <?php endif; ?> 
    <?php endwhile; ?>
<?php endif; ?>
4

1 に答える 1