WordPress.org

Ready to get started?Download WordPress

Forums

Random custom fields (1 post)

  1. imudo
    Member
    Posted 9 months ago #

    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 !

Reply

You must log in to post.

About this Topic