menardmam, this is my solution:
<?php $showPostsInCategory = new WP_Query(); $showPostsInCategory->query('cat=". $carouselCategory ."&showposts=". $carouselNumber ."');
if ($showPostsInCategory->have_posts()) : while ($showPostsInCategory->have_posts()) : $showPostsInCategory->the_post(); ?>
<li>
<?php $data = get_post_meta( $post->ID, 'key', true ); ?>
<?php foreach((get_the_category()) as $category) {echo ( $category->cat_name != $carouselCategory ) ? $category->cat_name . ' ' : '';}?>
<a href="https://wordpress.stackexchange.com/questions/45198/<?php if ($data["custom_link' ]) { echo $data[ 'custom_link' ];} else { the_permalink(); } ?>">
<?php the_post_thumbnail('sponsor', array('title' => "")); ?>
</a>
</li>
<?php endwhile; endif; ?>
The get_the_category
retrieves every category (parent and child) of your post, but by using the $category->cat_name != $carouselCategory
part the parent category won’t be displayed, just the child.