Get random terms

Unlike a normal WP_Query(), get_terms() or WP_Term_Query() does not have random ordering. You would either need to do it in SQL yourself or grab all the terms and shuffle them, pulling out 6 to make your random term array:

// Get all terms
$terms = get_terms( array(
    'taxonomy'      => 'webshops',
    'hide_empty'    => false,
) );

// Randomize Term Array
shuffle( $terms );

// Grab Indices 0 - 5, 6 in total
$random_terms = array_slice( $terms, 0, 6 );

Leave a Comment