Filtering out child category posts from parent category archive not working

The is_category function checks the queried object. Since this is in pre_get_posts, the query has not happened yet.

Check the other parameters to find if the query is going to be for cat 5, not if the results are for cat 5. Try ->get(‘cat’).