Actually the code you need is already in the documentation, it’s very much detailed and almost all user cases are explained there.
For example here
Follow these steps and be sure you are calling the fields from inside the loop!
http://codex.wordpress.org/The_Loop