I'm trying to display one of my custom taxonomy lists on a page.
I want to show five but have them in different random orders when the page is refreshed.
I've tried using shuffle, but it just shuffles the first 5 and you dont see any of the the others.
I tried orderby RAND
but it doesnt work. This is my code so far.
<?php
$all_artists = get_terms( 'artists', array(
"number" => 5,
'hide_empty' => 1,
'exclude' => array($cat->term_id),
) );
shuffle( $all_artists );
foreach ($all_artists as $cat) :?>
<li class='post'>
<a href="<?php echo get_term_link($cat->slug, 'directors'); ?>">
<div class='thumb-post'>
<img src="<?php echo z_taxonomy_image_url($cat->term_id, 'poster'); ?>" />
</div>
<h2> <?php echo $cat->name; ?></h2>
<p class='meta'>
</p>
</a></li>
<?php endforeach; ?>
number
parameter in the argument. In default all terms are returned. About ordering, there is no option to Random order. See official documentation