Yoast primary category query modification

I’m not sure this will fix it, but maybe try using the current category slug for the $current_category variable, instead of single_cat_title(), like so:

   $term = get_queried_object();
   $current_category = $term->slug;

This might help because the category_name parameter in WP_Query, despite its name, should be the term slug. single_cat_title() returns the displayed category title, not slug.