I use the code below, added to a template, to display random posts.
<ul>
<?php $posts = get_posts('orderby=rand&numberposts=5'); foreach($posts as $post) { ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php } ?>
</ul>
Do I need to reset, presumably by changing
<?php } ?>
to
<?php } wp_reset_postdata(); ?>
And does the need to reset depend on whether this code-block is before or after other loops/queries in the template?