WordPress.org

Support

Support » Plugins and Hacks » Random custom fields

Random custom fields

  • Hello,

    On my homepage, I have 6 blocks including some custom fields each.

    I would like to have a random display of these 6 blocks.

    My codes simply looks like this :

    <div class="bloc">
    <h2><?php the_field('titre1'); ?></h2>
    <div class="content">
    <p><?php the_field('description1'); ?></p>
    </div>
    <p class="more"><a href="<?php the_field('url1'); ?>">read more</a></p>
    </div>
    
    <div class="bloc">
    <h2><?php the_field('titre2'); ?></h2>
    <div class="content">
    <p><?php the_field('description2'); ?></p>
    </div>
    <p class="more"><a href="<?php the_field('url2'); ?>">read more</a></p>
    </div>
    
    <div class="bloc">
    <h2><?php the_field('titre3'); ?></h2>
    <div class="content">
    <p><?php the_field('description3'); ?></p>
    </div>
    <p class="more"><a href="<?php the_field('url3'); ?>">read more</a></p>
    </div>
    
    etc... (6 times)

    Do you know if there is a way to randomize this ?

    I thank you in advance for your help !

  • The topic ‘Random custom fields’ is closed to new replies.