WP_Query and using a variable for ‘cat’=> in the args array = WP Bug?

Where/how are you defining $category_id?

Reference the Codex entry for WP_Query() category parameters. WP_Query() expects category IDs to be passed as integers, not as strings:

  • If $category_id is an integer, pass it to 'cat'.
  • If $category_id is an array (of category IDs, again as integers), pass it to 'category__in'