在下面的代码中,我为banner_text和banner_text_two创建了一个随机文本。 知道我希望能够在显示banner_text时显示BUTTON 1,在显示banner_text_two时显示BUTTON 2.
Here is my random code for the two text fields:
<div class="plat">
<?php $random_text = array(
get_sub_field( 'banner_text' ),
get_sub_field( 'banner_text_two' ),
);
$rand = rand( 0, 1 );
echo $random_text[ $rand ]; ?>
</div>
BUTTON 1:
<a class="landing-page button" href="<?php echo home_url( '/superfly/' ); ?>">
<?php _e( 'Skateboard', 'superfly' ); ?> <i class="icon-arrow-right"></i></a>
BUTTON 2:
<a class="landing-page button" href="<?php echo home_url( '/fly/' ); ?>">
<?php _e( 'Fly away', 'fly' ); ?> <i class="icon-arrow-right"></i></a>
答案 0 :(得分:0)
<?php if($rand == 0){?>
<a class="landing-page button" href="<?php echo home_url( '/superfly/' ); ?>">
<?php _e( 'Skateboard', 'superfly' ); ?> <i class="icon-arrow-right"></i></a>
<?php }else{ ?>
<a class="landing-page button" href="<?php echo home_url( '/superfly/' ); ?>">
<?php _e( 'Skateboard', 'superfly' ); ?> <i class="icon-arrow-right"></i></a>
<?php } ?>