<div class="relatedPosts">
  <?php
$categories = get_the_category($post->ID);
if ($categories) {
    $category_ids = array();
    foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
echo ''; 
    $args=array(
        'category__in' => $category_ids,
        'post__not_in' => array($post->ID),
        'showposts'=>4, // Number of related posts that will be shown.
        'caller_get_posts'=>1
    );
  $my_query = new WP_Query($args);
  if( $my_query->have_posts() ) {
  while ($my_query->have_posts()) : $my_query->the_post(); ?>
  <ul class="relatedPostsUl">
    <li>
    	<div class="relatedPostContent">
            <a href="<?php the_permalink() ?>">
            	<?php the_post_thumbnail(); ?>
            </a>
        </div>
        <div class="relatedPostTitle">
        <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>" class="relatedTitle">
      		<?php the_title(); ?>
        </a>
        </div>
      </li>
  </ul>
  <?php
    endwhile;
  }
}
wp_reset_query();
?>
</div><!--End Related Posts-->