You need a custom query. codex ref
For instance,
$args = array(
'orderby' => 'rand',
'posts_per_page' => 20,
);
$query = new WP_Query( $args );
this query pick 20 random items. If you go above link, you can see more examples. I hope this will help you.