Next post in same category

On my WordPress homepage ( I am using the latest post widget to show posts from one category, and want the arrows at the bottom of the post to show next/previous posts in same category only.

I have changed the link-template.php file text line 2117 from false to true like below.

But the next/previous arrows still show posts from different categories as before. Is there any way around this?