https://wordpress.org/support/topic/random-category-list
<?php
//display random sorted list of terms in a given taxonomy
$counter = 0;
$max = 5; //number of categories to display
$taxonomy = 'category';
$terms = get_terms($taxonomy);
shuffle ($terms);
//echo 'shuffled';
if ($terms) {
foreach($terms as $term) {
$counter++;
if ($counter <= $max) {
echo '<p><a href="' . get_category_link( $term->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $term->name ) . '" ' . '>' . $term->name.'</a></p> ';
}
}
}
?>