I have the same problem/issue. Basically, the issue is to find the category id of the category under which the current post is stored, outside the loop.
$categoryvariable=$cat; // assign the variable as current category
$query= ‘cat=’ . $categoryvariable. ‘&orderby=date&order=ASC’; // concatenate the query
In this case, we are looking for whatever the value of the ‘$cat’ is, depending on the displayed post. Since it’s empty here, you get the most recent posts from all the categories.