Conditional Check in The Loop’s Parameters

I would change

$args = array(
      'category_name' => $category, 
      'showposts' => $numposts, 
      'order' => $order
    );

to

$args = array(
      'showposts' => $numposts, 
      'order' => $order
    );

if ( $category )
     $args['category_name'] = $category;

This way you never pass an empty category_name parameter as a query arg.