I’m not sure how much of a help this will be, but this is a (probably overly convoluted) snippet of code I wrote a few years ago for a shortcode to display posts by category. If nothing else it may at least put you on the right track.
$featured_posts = get_posts(
array(
'category' => $atts['cat'],
'posts_per_page' => -1
)
);