5
I have such a structure (which I created):
<div class="banners">
<?php echo do_shortcode("meubanner_1")?>
<?php echo do_shortcode("meubanner_2")?>
<?php echo do_shortcode("meubanner_3")?>
</div>
<div class="banners">
<?php echo do_shortcode("meubanner_4")?>
<?php echo do_shortcode("meubanner_5")?>
<?php echo do_shortcode("meubanner_6")?>
</div>
<div class="banners">
<?php echo do_shortcode("meubanner_7")?>
<?php echo do_shortcode("meubanner_8")?>
<?php echo do_shortcode("meubanner_9")?>
</div>
I need to randomize the results from 1 to 9 so that all banners when giving a refresh receive a variable with a random number and that does not repeat.
Something like: meubanner_$numeroaleatorio
. I don’t know exactly what this process is related to, loop or something else.
Hi Marcos, I edited the question tags and I assumed that is the
do_shortcode
of Wordpress. That’s right?– brasofilo
Well, I searched the web and there are no other instances of the function
do_shortcode()
. Only if it’s a custom function of yours, and if that’s the case, adjust the tags and give me a tap to adapt my response.– brasofilo
You can use the function Rand(initial number, final number), which is native <?php echo do_shortcode("meubanner_".Rand(0,10)); ? >. And of course you save on lines of code.
– Hiago Souza