next_post function is deprecated.
You should try this instead: next_post_link and previous_post_link
The basic way to use it is like so:
This will link to the next post or prev post.
<?php
next_post_link( '%link', '%title' );
previous_post_link( '%link', '%title' );
?>
If you would like to link to the next post in the same category, add true after ‘%title’. This will work for the default posts and category.
<?php
next_post_link( '%link', '%title', true );
previous_post_link( '%link', '%title', true );
?>
If you are using a CUSTOM POST TYPE with a CUSTOM TAXONOMY (like a product post), then you have to tell the function which taxonomy to look for the next post. eg.
<?php
next_post_link( '%link', '%title', true, '', 'custom_taxonomy' );
previous_post_link( '%link', '%title', true, '', 'custom_taxonomy' );
?>
All the above examples have been tested and working.