For my music archive WordPress theme, I needed to use wp_get_attachment_url in functions.php to grab a url that uses a custom field as follows:

ID, 'Audio File', true)); ?>

For some reason, WordPress wants to grab the post url rather than the file url. To fix this, I simply had to call the global $post variable as follows:


ID, 'Audio File', true)); ?>

That’s it! I am sure there is a different/better way to do this, so if you know how to accomplish this a different/better way, please let me know!

Thanks!