Forum
Randomly display a mutli item region on the homepage
Hello,
I have looked at the docs for displaying multi item regions, watched the swift migrations video on displaying different tutorials on load and the perch content custom function, however I can't get my code to work. The idea is to have a region (hero_image.html) appear on the homepage and for it to load a new image every time.
I have got so far:
<?php perch_content_custom('Hero Image', array(
'template'=>'hero_image.html',
'sort-order'=>'RAND',
'count'=>1
));
?>
This is only displaying one of the items when reloading the page.
This is the hero_image.html file:
<div class="hero-parallax" style="background-image: url('<perch:content id="hero_image" type="image" label="Hero Image" help="Image will be full width and height of screen" />');">
<div class="post-title-contain">
<div class="post-title">
<h1><perch:content id="hero_title" type="text" size="m" label="H1 Main Heading" textitle="true" html="true" editor="markitup" required="true" /></h1>
<hr class="title-line">
<p><perch:content id="hero_text" type="text" size="m" label="Name" textitle="true" html="true" editor="markitup" required="true" /></p>
<a href="#one"><div class="arrow bounce"></div></a>
</div>
</div>
</div>
Any help would be greatly appreciated! Thanks :)
Strange as it may seem, you need to set a value for
sort
to activate sorting. At that point thesort-order
value is used.Yes! I'm a numpty! Just for reference... I have added sort and it's working :)
Cheers Drew