trying to write a variable into a wp_query, need help!

Using get_posts():

 <?php
      $category = get_category_by_slug($post->post_name);
      $template =  $category->term_id;
      $taskarr = array(
           'post_type' => 'listing',
           'post_status' => 'publish',
           'category' => $template,
           'order' => 'ASC',
           'orderby' => 'meta_value_num',
           'meta_key' => 'listing_date'
      );
      $tasks = get_posts($taskarr);
      foreach( $tasks as $task ) {
           echo '<li>';
           echo $task->post_title;
           echo $task->post_excerpt;
           echo get_post_meta( $task->ID, 'location', 'single');
           echo '<li>';
      }
 ?>

Using WP_Query:

 <?php
       $catSlug = $post->post_name;
       $args = array(
           'post_type' => 'listing',
           'post_status' => 'publish',
           'category_name' => $catSlug,
           'order' => 'ASC',
           'orderby' => 'meta_value_num',
           'meta_key' => 'listing_date'

       );
       $the_query = new WP_Query( $args );
       while ( $the_query->have_posts() ) {
           $the_query->the_post();
           echo '<li>';
           the_title();
           the_excerpt();
           echo get_post_meta( get_the_ID(), 'location', 'single');
           echo '<li>';
  }
  wp_reset_postdata();

?>