【发布时间】:2013-11-18 21:39:10
【问题描述】:
在我的主页上,我有 6 个块,每个块包括一些自定义字段。
我想随机显示这 6 个方块。
我的代码看起来像这样:
<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)
你知道是否有办法随机化这个吗?
提前感谢您的帮助!
【问题讨论】:
-
您的意思是希望 6 个中的 1 个出现(随机挑选),还是希望它们随机排序但每次都显示全部 6 个?
-
第二个选项:我希望它们随机排序,每次显示 6 个,是的
标签: wordpress random custom-fields