Only link posts in same category
If you want your posts to only connect to posts in the same category, you can use the following snippet.
Note that this snippet only works for linking posts to posts and only works with the default category. You’re free to edit it to make it work on your custom post types and custom taxonomies of course!